Insert html into the descriptor template without escaping

Is there a way to insert a string with html tags into a descriptor template without getting the tags escaped in the outgoing string?

template.js:

<p>{{content}}</p> 

use pattern

 HBS.template({content: "<i>test</i> 123"}) 

actual result:

 <p>&lt;i&gt;test&lt;/i&gt; 123</p> 

Expected Result:

 <p><i>test</i> 123</p> 
+66
javascript
Nov 29 '13 at 7:37
source share
3 answers

Try

 <p>{{{content}}}</p> 

I got an official link to support my answer:

Handlebars HTML-escapes values ​​returned by {{expression}} . if you don’t want hand panels to escape the meaning, use the “triple stamp”, {{{ .

+151
Nov 29 '13 at 7:41
source share

In your template, you should add a triple mustache like this. <p>{{{content}}}</p>

+17
Nov 29 '13 at 7:41
source share

According to Handlebars documentation http://handlebarsjs.com/expressions.html

Quote from the documentation,

If you don't want Handlebars to avoid meaning, use "triple-stash", {{{

Pass the HTML source code for Handlebars and get the HTML source using triple brackets.

 {{{foo}}} 
+3
Feb 20 '17 at 7:19
source share



All Articles