问题
I´m using underscore to load a html template with by require.js with text.js, like code bellow:
template: _.template(listItemTemplate)
, render: function () {
$(this.el).html(this.template(this.model.toJSON));
return this;
}
tvListItemTemplate.html
<h4><%= _id%></h4>
If i do console.log(this.model.toJSON()) it prints the following:

But the console give me this error:

I don´t understand why
回答1:
Check with:
$(this.el).html(_.template(listItemTemplate, this.model));
or
template: function(x) {
_.template(listItemTemplate, x);
},
render: function () {
$(this.el).html(this.template(this.model));
return this;
}
回答2:
Sorry for that but it was a own stupid error in:
$(this.el).html(this.template(this.model.toJSON()));
来源:https://stackoverflow.com/questions/17993238/underscore-template-not-recognize-variables-on-template