https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.view.md
在这个例子中:
<script id="my-template" type="text/html">
I think that <%= showMessage() %>
</script>
MyView = Backbone.Marionette.ItemView.extend({
template: "#my-template",
templateHelpers: {
showMessage: function(){
return this.name + " is the coolest!"
}
}
});
model = new Backbone.Model({name: "Backbone.Marionette"});
view = new MyView();
view.render(); //=> "I think that Backbone.Marionette is the coolest!";
我已经尝试分析此代码,并且根据我对 Backbone 的理解,您必须指定视图与哪个模型相关联。我尝试理解 Marionette 视图,但我不知道文档的哪一部分或在此示例中显示视图如何知道this
指的是新创建的模型。或者这只是一个错字?