【发布时间】:2014-03-04 22:13:05
【问题描述】:
在 Grunt 的 package.json 中,我指定了一个把手编译器:
"grunt-contrib-handlebars": "0.7.0"
在 Gruntfile 中,我正在预编译把手模板:
handlebars:
compile:
options:
amd: true
namespace: false
files: [{
expand: true
cwd: 'src/mustache/',
src: ['**/*.mustache']
dest: 'public/js/compiled/templates'
ext: '.js'
}]
每个编译的模板都有一个需要把手的 AMD 包装器:
define(['handlebars'], function(Handlebars) {
return Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
...
在 Bower 的 bower.json 中,我指定了把手:
"handlebars": "1.3.0"
在我的 RequireJS 配置中,我指定了车把运行时:
require.config
baseUrl: '/js/compiled/'
paths:
'jquery': '../bower_components/jquery/jquery'
'underscore': '../bower_components/underscore/underscore'
'backbone': '../bower_components/backbone/backbone'
'handlebars': '../bower_components/handlebars/handlebars.runtime.amd'
...
(此处来源https://github.com/components/handlebars.js/blob/v1.3.0/handlebars.runtime.amd.js)
当编译的模板需要把手时
Handlebars = require 'handlebars'
车把未定义!我在这里做错了什么!?如有任何帮助,我将不胜感激!
我宁愿不使用任何 require 插件。
【问题讨论】:
标签: javascript requirejs gruntjs handlebars.js bower