Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading mustache using requirejs

I would like to load and use mustache by requirejs.

Maybe this question has already asked:
AMD Module Loading Error with Mustache using RequireJS

Anyway I am trying to figure out how can I fix my code:


main.js

require.config({
    paths: {
        jquery: 'libs/jquery/jquery',
        underscore: 'libs/underscore/underscore-min',
        backbone: 'libs/backbone/backbone-optamd3-min',
        mustache: "libs/mustache/mustache"
    }
});

require([
    'views/app'
    ], function(AppView){
        var app_view = new AppView;
 });

app.js

define([
    'jquery',
    'underscore', 
    'backbone',
    "mustache"
    ], function($, _, Backbone, Mustache) {
        console.log($, _, Backbone, Mustache); // <-- *** Mustache is null ***
        // ......
       }
);

As you can see in the comment on app.js file, Mustache is null...
Should I use another library of Mustache? Here what I am using Mustache

like image 806
user1328847 Avatar asked Apr 12 '12 11:04

user1328847


1 Answers

Looks like Mustache supports AMD modules as of July '12. So it should now work out of the box with a loader such as require.js.

like image 177
biril Avatar answered Sep 20 '22 06:09

biril