1

I'm looking about how to display HTML from a JS var.

I stocked it in a JSON, but when I want to display it (I return it from a meteor helper), it appears in plain text. I need it to treat the elements as HTML elements.

For example, if my var contains : "<a href='http://stackorverflow'>Go to the awesome site</a>"

I want it to display clearly as follow :

Go to the awesome site

I've looked for that on SO and google, but all I found was how to stock HTML to a var, not how to display it.

Could someone show me the way ?

Thanks you,

David

David Panart
  • 656
  • 6
  • 20
  • Checkout this answer: [Javascript variable access in HTML][1] [1]: http://stackoverflow.com/a/4772817/4896724 – ktothed May 21 '15 at 14:46

1 Answers1

0

By default, for safety purposes, Meteor will render any html code coming from helpers as "escaped" (visible) HTML. To render raw html in your template, Meteor Spacebars give us the triple-brace notation:

{{{html_var}}} <!-- this will be considered as html -->

Use this with caution though! Beware of XSS injections

SylvainB
  • 4,765
  • 2
  • 26
  • 39