我使用grunt-ember-templates预处理Handlebars模板。脚本按以下顺序排列:
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.runtime.min.js"></script>
<script src="/js/ember.min.js"></script>
<script src="/js/app.js"></script>
<script src="/build/templates.js"></script>
<script src="/js/router.js"></script>
.....
在templates.js
:
define(["ember"], function(Ember){
Ember.TEMPLATES["index"] = Ember.Handlebars.template(functionanonymous(Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Ember.Handlebars.helpers);
data = data || {};
var buffer = '', stack1, escapeExpression=this.escapeExpression, self=this;
function program1(depth0,data) {
var buffer = '';
...
.....
return buffer;
});
现在我得到Uncaught ReferenceError: define is not defined
错误,它引用define(["ember"], function(Ember){
。我做错了什么?
答案 0 :(得分:1)
在配置中将amd
设置为false:
emberTemplates: {
compile: {
options: {
amd: false,
templateBasePath: /path\/to\//
},
files: {
"path/to/result.js": "path/to/source.handlebars",
"path/to/another.js": ["path/to/sources/*.handlebars", "path/to/more/*.handlebars"]
}
}
}