Answer the question
In order to leave comments, you need to log in
Why doesn't Underscore parse the template?
There is a code:
BookApp.Views.KeyWord = Backbone.View.extend({
tagName: 'li',
initialize : function(){
this.render();
},
render : function(){
console.log(this.model.toJSON());
this.$el.html(_.template("( -<%= name %>- )",this.model.toJSON()) );
console.log(this.el);
return this;
}
})
Answer the question
In order to leave comments, you need to log in
Answer:
Because the _.template() method returns a function that takes parameters to be inserted into the compiled template by the _.template() method. Those.
var template = _.template("(<%= id %>) <%= name %>");
console.log(template({id:2, name:'Желток'}));
// (2) Желток
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question