Docly Developers
Function Updated 23 Oct 2026

htmlAttributeEncode(text)

The HtmlAttributeEncode method encodes characters appropriate for insertion into an HTML attribute value.

Parameters

textstringrequired

The 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}`);
}#