Insert html in a handlebar template without escaping

后端 未结 3 1389
醉酒成梦
醉酒成梦 2020-11-28 04:23

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:

&         


        
相关标签:
3条回答
  • 2020-11-28 04:58

    In your template you must add triple mustaches like this. <p>{{{content}}}</p>

    0 讨论(0)
  • 2020-11-28 05:14

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

    Quote from documentation,

    If you don't want Handlebars to escape a value, use the "triple-stash", {{{

    Pass the raw HTML to Handlebars template and get the raw HTML output by using triple brackets.

    {{{foo}}}
    
    0 讨论(0)
  • 2020-11-28 05:20

    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", {{{.

    0 讨论(0)
提交回复
热议问题