Monday, May 20, 2024
138
rated 0 times [  139] [ 1]  / answers: 1 / hits: 109175  / 11 Years ago, fri, november 29, 2013, 12:00:00

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



template.js:



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


use the template



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


actual outcome:



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


expected result:



<p><i>test</i> 123</p>

More From » handlebars.js

 Answers
17

Try like


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

official reference:



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



[#74001] Wednesday, November 27, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bobbyallanh

Total Points: 693
Total Questions: 120
Total Answers: 101

Location: Bermuda
Member since Thu, Apr 20, 2023
1 Year ago
;