View Helpers
stripLinks()
Signature
Section titled “Signature”stripLinks() — returns string
Available in: controller
Category: Sanitization Functions
Description
Section titled “Description”Removes all links from an HTML string, leaving just the link text.
Defaults to false (configurable per-function via
set(functionName=“stripLinks”, encode=true)). These helpers strip
markup; they are NOT an escaping strategy — when the goal is XSS-safe
output, use h() / hAttr() instead.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
html | string | yes | — | The HTML to remove links from. |
encode | boolean | no | true | Whether to HTML-encode the remaining text after stripping. |
Examples
Section titled “Examples”// 1. Remove a link from an HTML string, leaving only the link text
result = stripLinks('<strong>Wheels</strong> is a framework for <a href="http://www.adobe.com/products/coldfusion">ColdFusion</a>.');
// result -> "<strong>Wheels</strong> is a framework for ColdFusion."
// 2. Strip multiple links from a string
result = stripLinks('Visit <a href="https://cfwheels.org">CFWheels</a> or read the <a href="https://cfwheels.org/docs">docs</a> for more info.');
// result -> "Visit CFWheels or read the docs for more info."
// 3. Strip links while skipping XSS encoding (e.g. when you trust the source HTML)
result = stripLinks('<p>Check out <a href="https://cfwheels.org">CFWheels</a>!</p>', encode=false);
// result -> "<p>Check out CFWheels!</p>"