45

私はJavaScriptでこのような配列を持っています:

[name: "myname", text: "<p>my html text</p>"]

これをMustacheテンプレートで使用すると、テキストが次のように表示されます。

<p>my html text</p>

次のように、HTMLとして表示したいだけです。

my html text

-

私が使用するテンプレートは次のようなものです。

<div>
    {{name}}
    {{html}}
</div>
4

1 に答える 1

121

use triple curly braces if you want to output html. {{{html}}}

from the docs:

All variables are HTML-escaped by default. If you want to render unescaped HTML, use the triple mustache: {{{name}}}. You can also use & to unescape a variable.

https://github.com/janl/mustache.js/

于 2012-10-11T07:36:58.230 に答える