使用Meteor插入HTML标记

Ale*_*own 27 html markup templates meteor

如何在Meteor模板中显示标记的字符串数据?

我需要在我的数据库中显示一个包含一些基本HTML标记的字符串,以便生成的文本格式正确.它目前只显示标记文本.

这是模板的相关部分:

<span class="description">{{description}}</span>
Run Code Online (Sandbox Code Playgroud)

其中{{description}}是包含标记的字符串(如"hello <br> world").

我想要它显示

hello
world
Run Code Online (Sandbox Code Playgroud)

而不是

hello<br>world
Run Code Online (Sandbox Code Playgroud)

我想这与在javascript中使用innerHTML类似.

提前致谢!

ram*_*am1 63

要在Handlebars中覆盖HTML-escape,请使用triple-stash:

<span class="description">{{{description}}}</span>
Run Code Online (Sandbox Code Playgroud)

  • 多么简单!! 这需要一千多个upvotes :) (2认同)