Articles in this section

Escape Handlebars expressions

By default, Handlebars evaluates any expression in a template. To render an expression as literal text instead, escape it. You can escape a single expression inline with a backslash (\), or escape a block of content with a raw block.

Escape an expression inline

Prefix an expression with a backslash (\) to render it literally instead of evaluating it.

Template

\{{escaped}}

Output

{{escaped}}

Escape a block with a raw block

Wrap content in a raw block — four braces ({{{{ }}}}) on the opening and closing tags — to render everything inside it literally.

Template

{{{{raw}}}}{{escaped}}{{{{/raw}}}}

Output

{{escaped}}

Escape one expression among several

You can escape a single expression while the others in the same template still evaluate. In this example, the add expression is escaped and renders literally, while subtract and divide evaluate.

Template

\{{add 3 4 }}
{{subtract 100 5}}
{{divide 365 5}}

Output

{{add 3 4 }}
95
73