shawnXiao
shawnXiao

Reputation: 880

handlebars in requirejs load not successfully

paths: {
          jquery: 'libs/jquery/jquery-min',
          underscore: 'libs/underscore/underscore-min',
          backbone: 'libs/backbone/backbone-optamd3-min',
          handlebars: 'libs/handlebars/handlebars',
          text: 'libs/require/text'
      }

   define([
      'jquery',
       'underscore',
       'backbone',
       'collections/todos',
       'views/todos',
       'text!templates/stats.html',
       'common',
       'handlebars'
  ], function ($, _, Backbone, Todos, TodoView, statsTemplate, Common, handlebars) {
   //handlebars is null
   console.log("handlebars is",handlebars);

})

Except handlebars,others can load successfully.Why and how to make handlbars load successfully.thanks

Upvotes: 4

Views: 10088

Answers (1)

Simon Smith
Simon Smith

Reputation: 8044

Firstly, I can see that you're new but please try to add more detail to your question to help others help you.

From glancing at the source I don't think Handlebars is compatible with AMD, therefore you will need to shim it yourself. Something like this:

requirejs.config({
    shim: {
        'handlebars': {
            exports: 'Handlebars'
        }
    }
});

Upvotes: 30

Related Questions