简体   繁体   中英

handlebars show html tags instead of treat it as html tags

i've got handlebars template which i fill by some complex message (with html stuff like images, bold texts etc...). I don't know how to force this library to treat my message text as valid html-nodes with some text stuff.

I'm doing something like this:

<div class="title">
    <strong>
        <a href="/Home/Post/{{this.MESSAGE_ID}}">{{this.MESSAGE_TITLE}}</a>
    </strong>
</div>

where {{this.MESSAGE_TITLE}} can be correct html content.

Try with & after the {{ or {{{

{{&this.MESSAGE_TITLE}}

or

{{{this.MESSAGE_TITLE}}}

From the mustache website where handlebars is derived from...

All variables are HTML escaped by default. If you want to return unescaped HTML, use the triple mustache: {{{name}}}.

You can also use & to unescape a variable: {{& name}}. This may be useful when changing delimiters

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM