Search code examples
htmltemplatesmeteormarkup

Insert HTML markup using Meteor


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!


Solution

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

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