Avoiding HTML encoding in function return values

By default the handlebars engine will HTML escape every value it returns into the template.

What this means is that if the value returned from any function contains one of the HTML special characters, then they will be replaced with their escaped equivalent.

CharacterDescriptionEscaped Equivalent

&

Ampersand

&

<

Less than

&lt;

>

Greater than

&gt;

"

Double quote

&quot;

'

Single quote

&apos; or &#39;

©

Copyright symbol

&copy;

®

Registered symbol

&reg;

Trademark symbol

&trade;

In order to avoid this behavior, you need to enclose the function in triple handlebar syntax.

for example:

{{faker 'Question'}} 

might return

You probably haven&apos;t heard of them?

where as, if used with triple handlebars:

{{{faker 'Question'}}} 

might return

You probably haven't heard of them?

Last updated