Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 717
shawnXiao Avatar asked Nov 27 '22 09:11

shawnXiao


1 Answers

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'
        }
    }
});
like image 163
Simon Smith Avatar answered Dec 06 '22 10:12

Simon Smith