2

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,008
  • 28
  • 81
  • 143
  • 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

7

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
  • 396,305
  • 64
  • 779
  • 743