简体   繁体   English

把手显示html标签而不是将其视为html标签

[英]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...). 我有把手模板,我填写一些复杂的消息(与图像,粗体文本等html的东西......)。 I don't know how to force this library to treat my message text as valid html-nodes with some text stuff. 我不知道如何强制这个库将我的消息文本视为具有一些文本内容的有效html节点。

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. 其中{{this.MESSAGE_TITLE}}可以是正确的html内容。

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. 默认情况下,所有变量都是HTML转义的。 If you want to return unescaped HTML, use the triple mustache: {{{name}}}. 如果要返回未转义的HTML,请使用三重胡须:{{{name}}}。

You can also use & to unescape a variable: {{& name}}. 您还可以使用&来取消变量:{{&name}}。 This may be useful when changing delimiters 这在更改分隔符时可能很有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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