How to return html tag from template helper?


I would to return the html tag from template helper like this

// Register helper
fontAwesome = function (name) {
    return '<i class="fa fa-' + name + '"></i>';

Template.registerHelper('fa', fontAwesome);
// in template.html
{{fa "plus"}}

but it show html tag in browser.
how to show the font icon?

Rendering HTML using Views, Blaze.render and Blaze.renderWithData

Use triple braces:

{{{fa "plus"}}}

Or return a Spacebars.SafeString object:

// Register helper
fontAwesome = function (name) {
    return Spacebars.SafeString('<i class="fa fa-' + name + '"></i>');

Beware that Spacebars.SafeString is not a safe string! It should have been called Spacebars.UnsafeString, as it does not perform any sanitization.


Very thanks, work fine :heart_eyes: