htmlAttributeEncode(text) Last updated: 30. May 2026
The HtmlAttributeEncode method encodes characters appropriate for insertion into an HTML attribute value.
Parameters
| Name | Type | Description |
|---|---|---|
| text | string | The string to encode |
Returns
An encoded string.
Example
Code example (#JS)
#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.#{
let myString = "<a href=\"test\"></a>";
// Encode the string.
let myEncodedString = docly.htmlAttributeEncode(myString);
write(`HTML Encoded string is: ${myEncodedString}`);
}# Output
The #JS code above produces the output shown below:HTML Encoded string is: <a href="test"></a>