1

I have "name" variable in the view and I want to display something like this in the rendered HTML:

${Jon}

Right now, my code is like this:

<li>
  {{name}}
</li>

I am storing name in the view directly as "${" + model.name + "}". But I dont want to store names this way, I want to display the characters $, { and } in the handlebars template.

How to you escape { and } in the handlebars to be normal strings?

Dhwaneet Bhatt
  • 601
  • 1
  • 8
  • 19

1 Answers1

4

You can use the HTML ASCII code:

&#123; = '{'
&#125; = '}'

example:

<li>&#123;{{item}}&#125;</li>

if item = 'apple', then this becomes:

{apple}

JSBin example

CraigTeegarden
  • 8,173
  • 8
  • 38
  • 43