使用 Meteor 插入 HTML 标记 [英] Insert HTML markup using Meteor

查看:20
本文介绍了使用 Meteor 插入 HTML 标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How can I display marked up string data in a Meteor template?

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

I need to display a string from my database that contains some basic HTML tags such that the resulting text is properly formatted. It currently just displays the markup text.

这是模板的相关部分:

<span class="description">{{description}}</span>

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

Where {{description}} is the string containing markup (like "hello<br>world").

我希望它显示

hello
world

而不是

hello<br>world

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

I guess this would be similar to using innerHTML in javascript.

提前致谢!

推荐答案

要覆盖 Handlebars 中的 HTML-escape,请使用三重存储:

To override HTML-escape in Handlebars, use the triple-stash:

<span class="description">{{{description}}}</span>

这篇关于使用 Meteor 插入 HTML 标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆