次のコードでテンプレートを正しくレンダリングすることができました。home
プリコンパイルされたテンプレート名です。
app.HomeView = Backbone.View.extend({
el: '#main',
template: 'home',
render: function(){
var self = this;
dust.render(this.template, {name:'world'}, function(err,out){
self.$el.html(out);
});
return this;
}
});
self
しかし、私は多くのテンプレートを持っているので、そしてほこりのコールバックのものを台無しにすることはあまりきれいではありません。
アンダースコアテンプレート(次のように表示)を使用するのと同じように、クリーンアップすることはできますか?
template: _.template( $('#some-template').html() ),
render: function(){
this.$el.html(this.template( {name:'world'} ));
return this;
}