The character escaping functions $esc.html and
$esc.xml can be applied to content in order to generate valid XML and HTML output.
You can escape characters manually, for example by typing > instead of
> when you write your template. You can also use the
$esc.html function to escape characters. Use the following syntax:
The <string> argument is a sequence of characters. You can use variables.
This function will automatically replace characters in the string with the corresponding escape sequences. For example, if you type
$esc.html('The <p> tag') in your template, the output will be
The <p> tag. You will get the same result if you use a variable as argument:
Character escaping for XML is almost identical to character escaping for HTML. The difference is that you use the
$esc.xml function to escape characters. The following five characters must be escaped in order to generate valid XML output: