Search code examples
javascriptmeteorhandlebars.jsmeteor-helper

How to return html element from helper?


I need to add html element form helper. Is there a way?

Template:

<template name="Index">
 <div class="title"> {{title}} </div>
</template>

JS

Template.Index.helpers({
  title: function(){
    var testvariable = "Hello <b>World</b>";
    return testvariable;
  }
})

Note: The below method will work fine. But in my case the title string is dynamic content.

<div class="title"> Hello <b>{{title}}</b> </div>
var testvariable = "World";

Solution

  • You'll need to use triple braces like this:

    {{{ title }}}
    

    Check the docs for more infos.