In Grunt's package.json I've specified a handlebars compiler:
"grunt-contrib-handlebars": "0.7.0"
In the Gruntfile I'm precompiling the handlebars templates:
handlebars:
compile:
options:
amd: true
namespace: false
files: [{
expand: true
cwd: 'src/mustache/',
src: ['**/*.mustache']
dest: 'public/js/compiled/templates'
ext: '.js'
}]
Each compiled template has an AMD wrapper that requires handlebars:
define(['handlebars'], function(Handlebars) {
return Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
...
In Bower's bower.json I've specified handlebars:
"handlebars": "1.3.0"
In my RequireJS config I'm specifying the handlebars runtime:
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'
...
(source here https://github.com/components/handlebars.js/blob/v1.3.0/handlebars.runtime.amd.js)
When the compiled template requires handlebars
Handlebars = require 'handlebars'
Handlebars is undefined! What am I doing wrong here!? I'd appreciate any help!
I'd prefer to not use any require plugins.