我正在使用 Mustache 来渲染模板。
我有这个 JSON 对象:
{
title: "Foo bar",
content: "<p> Html here </p>",
footer: "footer content here"
}
我有一个 Mustache 模板,如下所示:
<div id="box">
<div id="title"> {{title}} </div>
<div id="content"> {{content}} </div>
<div id="footer"> {{footer}} </div>
</div>
我的问题是,变量内容中的HTML没有被渲染,而是直接被打印到屏幕上。
我在非查看源代码的窗口中看到的是:<p>这里是HTML</p>
,如果我只查看页面源代码,我只想看到它。
我该如何修复这个问题,使得当我将字符串传递给Mustache模板时,其中的HTML能够被渲染?我调用了mustache.render(templates.all,data); 作为对Mustache的调用。