我刚开始使用 Mustache,我遇到了这个渲染问题。我通过渲染函数发送数据:
return Mustache.render(html, data);
或
return Mustache.to_html(html, data);
但是当我将它附加到一个 div 时:
$('#jqt').append(html);
它以实际文本返回这样的结果:
<div id="product_search_view"><form class="search-form" ><ul class="rounded"><li><input type="text" id="label" name="search" placeholder="Enter what you are looking for"></li></ul><a href="#" class="whiteButton submit" id="search-button" >Search</a></form><ul id="search-results" class="edgetoedge"></ul></div>
我怎样才能让 mustache 不放入那些字符?
最佳答案
似乎您将已解析的 HTML 传递给了 Mustache。
这是 a section of the documentation解决转义字符和“三重 mustache ”的使用问题。
此外,here's another documentation .阅读标签类型部分和使用 &
来防止转义。
关于javascript - Javascript 的 mustache 渲染问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10654613/