我正在使用require
手柄插件(https://github.com/SlexAxton/require-handlebars-plugin),我也集成到我的应用中......
这是我的模板:(作为样本)
<div class="best plugin ever">
This is my {{ adjective }} template.
</div>
在view.js中我调用模板并编译:
define([
'jquery',
'underscore',
'backbone',
'hbs!scripts/login/template/login1Temp.hbs'],
function ($,_,Bacbone,loginTemplate) {
"use strict";
socialApp = window.socialApp || {};
socialApp.loginView = Bacbone.View.extend({
el:'div#header',
initialize:function(){
var html = loginTemplate({adjective: "favorite"}) //i am using handlebars temp.
this.$el.html("<p>This is weekend! </p>"); //it works
this.$el.html(html); //it not working, i am getting my static html duplicates!
}
});
return socialApp.loginView;
}
);
答案 0 :(得分:0)
从define
删除文件扩展名后,它工作正常。可怜的医生让这场斗争成为现实。
define([
'jquery',
'underscore',
'backbone',
'hbs!scripts/login/template/login1Temp'], //removed the extension.
function ($,_,Bacbone,loginTemplate) {
"use strict";
socialApp = window.socialApp || {};
socialApp.loginView = Bacbone.View.extend({
el:'div#header',
initialize:function(){
var html = loginTemplate({adjective: "favorite"}) //i am using handlebars temp.
this.$el.html("<p>This is weekend! </p>"); //it works
this.$el.html(html); //it not working, i am getting my static html duplicates!
}
});
return socialApp.loginView;
}
);