相关疑难解决方法(0)

Ember.js如何引用Grunt.js预编译的Handlebars模板?

我一直在探索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)

javascript node.js handlebars.js ember.js gruntjs

9
推荐指数
1
解决办法
2950
查看次数

标签 统计

ember.js ×1

gruntjs ×1

handlebars.js ×1

javascript ×1

node.js ×1