I have a template file test_temp.handlebars. Its content is,
<div>Hello {{name}}</div>
I compiled the template in my command line using the command,
handlebars test_temp.handlebars -f test_temp.js
The content of the test_temp.js file is,
(function() {
var template = Handlebars.template, templates = Handlebars.templates =Handlebars.templates || {};
templates['test_temp'] = template({"compiler":[5,">=2.0.0"],"main":function(depth0,helpers,partials,data) {
var helper, functionType="function", escapeExpression=this.escapeExpression;
return "<div>Hello "
+ escapeExpression(((helper = helpers.name || (depth0 && depth0.name)),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "</div>\n";
},"useData":true});
})();
Now i read my precompiled template in my html.
var compiledTemplate = Handlebars.templates['test_temp'];
var temp_html = compiledTemplate({ name: 'World' });
console.log(temp_html); //undefined
Here the value returned to the temp_html is undefined.
Kindly let me know how to put this temp_html inside a div.
$("#tempdiv").html(temp_html);
When I update the temp_html inside the div, the error thrown is,
"Uncaught TypeError: undefined is not a function"
How to get the precompiled template value and insert it inside a div.