gpt4 book ai didi

Mustache Js 将 html 标记渲染为 html

转载 作者:行者123 更新时间:2023-12-02 18:54:38 24 4
gpt4 key购买 nike

我们正在使用 Mustachejs 转换旧的 CMS。内容的主体包含一些 html 元素:

<strong>Mickey Mouse</strong> is a funny animal cartoon character created in 1928 by Walt Disney.

我们将值应用到 Mustachejs,例如 {{Description}}

渲染的输出是

<strong>Mickey Mouse</strong> is a funny animal cartoon character
created in 1928 by Walt Disney.

Mustachejs 按字面意思显示数据库中的值。

我们如何让 Mustachejs 将 html 标记渲染为 html?

期望的结果

米老鼠是一个有趣的动物卡通人物 由沃尔特·迪士尼于 1928 年创建。

最佳答案

它并不是按字面意思显示数据库中的值,而是对其进行编码。它实际上正在输出

&lt;strong&gt;Mickey Mouse&lt;/strong&gt;

使用 {{{third_braces}}} 来渲染 Mustache,而不需要对字符串进行 html 编码。 {{{描述}}}

关于Mustache Js 将 html 标记渲染为 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15262459/

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