I recently precompiled a handlebars template manually and saved it as "testTemplate.handlebars."
Now, in my code using requireJS and Backbone, I have the following function:
define(['text!../templates/testTemplate.handlebars'
],function(testTemplate){
var myView = Backbone.View.extend(
initialize: function(options){
this.template = Handlebars.template(testTemplate);
},
render: function(data){
$(this.el).html(this.template(data));
}
);
});
When I log the value of 'this.template' to the console, I see:
function (n,r){return r=r||{},e.call(t,Handlebars,n,r.helpers,r.partials,r.data)}
However, when the line
$(this.el).html(this.template(data));
is executed within the render function, an error occurs stating: Uncaught Typeerror : object has no method call. (Even though there seems to be a 'call' method present)
Is there something incorrect with my approach?
Interestingly, if I compile the template at runtime instead, the render function works fine. Upon compiling at runtime using Handlebars.compile(testTemplate), the returned function looks like this:
function (e,t){return n||(n=r()),n.call(this,e,t)}