HtmlAttributeEncode(text) Last updated: 13. Nov 2023

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

Parameters

Name Type Description
text string The string to encode

Returns

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: &lt;a href=&quot;test&quot;>&lt;/a>