Skip to content

Instantly share code, notes, and snippets.

@jakelazaroff
Last active December 20, 2015 12:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakelazaroff/6131369 to your computer and use it in GitHub Desktop.
Save jakelazaroff/6131369 to your computer and use it in GitHub Desktop.
RequireJS module example. This is how I keep my dependency list organized!
define([
// models
'models/someModel', 'models/someOtherModel',
// collections
'collections/someCollection',
// views
'views/someView', 'views/someOtherView',
// templates
'text!templates/someTemplate.html', 'text!templates/someOtherTemplate.html',
// plugins
'vendor/jquery/somePlugin'
], function (
// models
someModel, someOtherModel,
// collections
someCollection,
// views
someView, someOtherView,
// templates
someTemplate, someOtherTemplate,
) {
// ...
});
@danharper
Copy link

How about:

define(function(require) {
    var someModel = require('models/someModel'),
        someOtherModel = require('models/someOtherModel'),
        someCollection = require('collections/someCollection');

    // ...

});

I find this syntax is easier to handle for larger dependency lists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment