0
我最近需要移动到所有我的模板使用JST文件,所以我没有混乱的HTML模板无处不在。Backbone/Marionette JST模板 - 没有错误,但没有显示查看
我使用grunt(使用grunt-contrib-jst)构建JST文件并创建文件“build/templates.js”。
下面是有一个条目:
this["JST"] = this["JST"] || {};
this["JST"]["build/html/template-1.html"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape;with (obj) {__p += ' <script type="text/template" id="template-1">\n <span id="chat_title_1">' +((__t = (title)) == null ? '' : __t) +'</span>\n <span id="chat_symbol_1">▲</span>\n </script>';}return __p};
我更新了我的backbone.marionette渲染方法按https://github.com/marionettejs/backbone.marionette/wiki/Using-jst-templates-with-marionette,在它要求更换Renderer.render方法。请参见下面的变化:
Marionette.Renderer = {
render: function(template, data){
if (!JST[template]) throw "Template '" + template + "' not found!";
return JST[template](data);
}
};
所以我在我的观点如下:
App.ChatBoxView = Backbone.Marionette.Layout.extend({
template: "build/html/template-1.html",
...
该页面加载,没有错误或任何东西,但并没有什么渲染页面,没有意见等
有什么缺失或做错了吗?
谢谢。