Insert HTML markup using Meteor

无人久伴 提交于 2019-12-18 12:47:26

问题


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

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.

Here's the relevant part of the template:

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

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

I'd like it to display

hello
world

rather than

hello<br>world

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

Thanks in advance!


回答1:


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

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


来源:https://stackoverflow.com/questions/14267856/insert-html-markup-using-meteor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!