我一直在探索Ember.js和Grunt.js,但我无法理解Ember.js如何能够找到并使用预编译的Handlebars模板.现在我的Gruntfile.js看起来像这样:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
handlebars: {
compile: {
files: {
"js/templates.js": "templates/*.hbs",
}
}
}
});
// Load the plugin that handles the handlebars compiling
grunt.loadNpmTasks('grunt-contrib-handlebars');
// Default task(s).
grunt.registerTask('default', ['handlebars']);
};
Run Code Online (Sandbox Code Playgroud)
并且我的app.js Ember视图被声明为(路由和控制器被省略):
App.LogoView = Ember.View.extend({
templateName: 'logo',
classNames: ['logo']
});
App.TabsView = Ember.View.extend({
templateName: 'tabs',
classNames: ['tabs']
});
App.TabView = Ember.View.extend({
classNames: ['content'],
tabPositions: {
tab1: {
width: '90px',
left: '82px'
},
tab2: {
width: '180px',
left: '172px'
},
tab3: { …Run Code Online (Sandbox Code Playgroud)