我已按照本教程http://kroltech.com/2013/12/boilerplate-web-app-using-backbone-js-expressjs-node-js-mongodb/设置了我的后端node.js服务器,但改为我想要尝试炭烬的前端使用骨干牵线木偶的方法。因此,在成功设置服务器之后,我现在将继续学习本教程http://emberjs.com/guides/getting-started/。
我遇到的问题是将外部模板包含在余烬路由中。使用此代码和在浏览器中编写的todos模板,该应用程序可以正常运行。
var Ember = require('ember');
window.Todos = Ember.Application.create();
Todos.Router.map(function() {
this.resource('todos', { path: '/' });
});
但是,使用在./templates/application.hbs中编写的模板并使用browserify尝试此操作,
Todos.Router.map(function() {
this.resource(require('./templates/application.hbs'), { path: '/' });
});
我得到如下所示的错误。
Uncaught TypeError: undefined is not a function myapp.js:46841
Error: Assertion Failed: The URL '/' did not match any routes in your application
at new Error (native)
at Error.Ember.Error (http://localhost:3300/js/myapp.js:12978:19)
at Object.Ember.assert (http://localhost:3300/js/myapp.js:12141:11)
at http://localhost:3300/js/myapp.js:47347:15
at invokeCallback (http://localhost:3300/js/myapp.js:22081:19)
at publish (http://localhost:3300/js/myapp.js:21751:9)
at publishRejection (http://localhost:3300/js/myapp.js:22179:7)
at http://localhost:3300/js/myapp.js:30448:7
at Object.DeferredActionQueues.flush (http://localhost:3300/js/myapp.js:18195:24)
at Object.Backburner.end (http://localhost:3300/js/myapp.js:18283:27) myapp.js:15589
Uncaught Error: Assertion Failed: Error: Assertion Failed: The URL '/' did not match any routes in your application
我希望有人可以阐明如何在余烬路由器中包括外部模板。谢谢!
感谢您的关注!我认为我在解释我的问题时做得很差-我知道这是模板名称,但我不知道如何在应用程序中包含该名称。我搜索了更多内容,然后找到了grunt-ember-templates
。
为了将来参考,他们提供了非常好的文档来帮助您进行设置,这就是我的emberTemplates代码的样子。
emberTemplates: {
compile: {
options: {
templateBasePath: 'client/src/templates'
},
files: {
'build/templates.js': ['client/src/templates/*.hbs']
}
}
},
然后我刚刚添加'application'
了我的路由模板名称。不要忘记在应用程序构建中编译所有build /。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句