4

Handlebar template

<div>
    {{contentText}}
</div>

JS

var contentText = {contentText: "<table><tr><td>Some Data<\/td><\/tr><\/table>"}

Handle bars render displays the HTML as string rather than rendering the HTML.

Where am I going wrong ?

Anand Sunderraman
  • 7,900
  • 31
  • 90
  • 150
  • Possible duplicate of [Handlebars Template rendering template as text](https://stackoverflow.com/questions/7168469/handlebars-template-rendering-template-as-text) – MathKimRobin Jul 03 '19 at 14:14

1 Answers1

9

From the fine manual:

Handlebars HTML-escapes values returned by a {{expression}}. If you don't want Handlebars to escape a value, use the "triple-stash", {{{.

So if you want to put contentText straight into the template as-is then you want:

<div>
    {{{contentText}}}
</div>

in your template.

Demo: http://jsfiddle.net/ambiguous/f7LJ5/

mu is too short
  • 426,620
  • 70
  • 833
  • 800