Reputation: 36391
I am trying to make a module that uses jQuery and Handlebars
This is the main file:
require(['app', 'jquery', 'handlebars' ], function (app, $, handlebars) {
console.log('Running jQuery %s', $().jquery);
});
And this is the app file:
define(['jquery', 'handlebars'], function ($, hb) {
$(function() {
var source = $("#some-template").html();
var template = hb.compile(source);
var data = {...});
});
Why is does it say hb is not defined
but when I remove all dependencies it works when using Handlebars
instead of hb
(which is the normal way)?
Upvotes: 0
Views: 300
Reputation: 3113
Handlebars is not AMD/RequireJS compliant. You will need to shim
it: http://requirejs.org/docs/api.html#config-shim
shim: {
handlebars: {
exports: 'Handlebars'
},
}
Upvotes: 2