gpt4 book ai didi

javascript - Javascript 的 mustache 渲染问题

转载 作者:搜寻专家 更新时间:2023-10-31 22:03:30 25 4
gpt4 key购买 nike

我刚开始使用 Mustache,我遇到了这个渲染问题。我通过渲染函数发送数据:

return Mustache.render(html, data);

return Mustache.to_html(html, data);

但是当我将它附加到一个 div 时:

$('#jqt').append(html);

它以实际文本返回这样的结果:

<div id="product_search_view">&lt;form class="search-form" &gt;&lt;ul class="rounded"&gt;&lt;li&gt;&lt;input type="text" id="label" name="search" placeholder="Enter what you are looking for"&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a href="#" class="whiteButton submit" id="search-button" &gt;Search&lt;/a&gt;&lt;/form&gt;&lt;ul id="search-results" class="edgetoedge"&gt;&lt;/ul&gt;</div>

我怎样才能让 mustache 不放入那些字符?

最佳答案

似乎您将已解析的 HTML 传递给了 Mustache。

这是 a section of the documentation解决转义字符和“三重 mustache ”的使用问题。

此外,here's another documentation .阅读标签类型部分和使用 & 来防止转义。

关于javascript - Javascript 的 mustache 渲染问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10654613/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com