在mustachejs中的未转义html中呈现变量

问题描述 投票:1回答:2

[我知道使用3个方括号会取消html的显示,但是如果此html具有要渲染的变量,该怎么办

{
 body: "<p> this is a {{message}} </p>",
 message: "Hello World"
}
{{{ body }}}

渲染

this is a

我希望成为

this is a message
javascript html mustache
2个回答
0
投票

如果要获取对象本身的值,则需要使其返回要在可引用this的函数调用中构建的字符串。>

下面显示的wat是简单的javascript。


0
投票

在胡须中,您可以使用函数进行渲染。因此,稍微改变一下视图基准,就可以实现您的愿望:

© www.soinside.com 2019 - 2024. All rights reserved.