我有一个简单的 mustache 函数,它获取一个模板,处理它,然后我使用 $().append 将它插入到我需要的地方。
问题是它实际上呈现的是 html 标签,而不仅仅是文本。
代替:
paragraph1...
paragraph2...
确实如此(实际上显示了 html 标签):
<p>paragraph1</p>
<p>paragraph2</p>
我的 mustache 函数:
$.get(baseUrl+"js_temp/template.html", function(templates) {
tab.append(Mustache.render(templates, templateData));
});
模板.html:
<div>
{{content}}
</div>
非常标准的东西......直到大约 2 天前它都运行良好......我无法弄清楚我可以做些什么来导致这个。
谁能指出我为什么会发生这种情况的正确方向?
谢谢!
最佳答案
也许尝试使用 3 {{{content}}}
?
All variables are HTML-escaped by default. If you want to render unescaped HTML, use the triple mustache:
{{{name}}}
. You can also use & to unescape a variable.
我在 mustache 的 git repo 上得到了这个。
关于javascript - Mustache 在 dom 中渲染实际的 HTML 标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16114012/