Function Updated 23 Oct 2026
htmlAttributeEncode(text)
The HtmlAttributeEncode method encodes characters appropriate for insertion into an HTML attribute value.
Parameters
textstringrequiredThe string to encode
Returns
An encoded string.
Example
Mixed HTML (or any text file) with inline JavaScript between hash signs.
#{
let myString = "<a href=\"test\"></a>";
// Encode the string.
let myEncodedString = docly.htmlAttributeEncode(myString);
write(`HTML Encoded string is: ${myEncodedString}`);
}#The template above produces this output:
HTML Encoded string is: <a href="test"></a>