Converts special characters in a string (such as <, >, &, ', ") into their encoded entity forms. Use it when you need to safely store or transmit text that may include reserved characters.
-
Encode HTML-sensitive characters
{{htmlEncode record.content}}Input:
{ "record": { "content": "<div class='alert'>& Goodbye \"world\"</div>" } }Output:
<div class='alert'>& Goodbye "world"</div>
Tip
-
Use this helper when sending data that should not be interpreted as markup, such as embedding text inside HTML templates or storing raw text in databases.
-
Only special characters are converted; plain text remains unchanged.
-
Combine with
htmlDecodeif you need to safely switch between encoded and decoded forms.