I have a template file precompile.handlebars. Its content is,
<div>Hello {{name}}</div>
I compiled the template in my command line using the command,
ember-precompile precompile.hbs -f precompile.js
The content of the precompile.js file is,
Ember.TEMPLATES["precompile"] = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {};
var buffer = '', hashTypes, hashContexts, escapeExpression=this.escapeExpression;
data.buffer.push("<h2>Welcome to Ember.js ");
hashTypes = {};
hashContexts = {};
data.buffer.push(escapeExpression(helpers._triageMustache.call(depth0, "name", {hash:{},contexts:[depth0],types:["ID"],hashContexts:hashContexts,hashTypes:hashTypes,data:data})));
data.buffer.push("</h2>");
return buffer;
});
Now i read my precompiled template in my html.
var temp = Em.TEMPLATES['precompile'];
var temp_html = temp({name: "Ram Chiranjeevi"});
$("#testdiv").html(temp_html);
TypeError: Cannot read property ‘push’ of undefined error message is thrown. I need to load the template inside an element in my html.
Thanks Jeevi