Skip to content

Instantly share code, notes, and snippets.

@wycats
Forked from jrburke/oneOutOfMany.js
Created February 8, 2011 00:29
Show Gist options
  • Save wycats/815596 to your computer and use it in GitHub Desktop.
Save wycats/815596 to your computer and use it in GitHub Desktop.
/*
Define a library called foo that has a parse and render
functionality, and a utility function called escape.
*/
/** foo.js **/
//If wanting a global, declare it here
var foo;
//Assemble foo from parts
define([
//exports is special, it creates an empty object
//for foo immediately.
'exports',
//loads parse.js as a sibling to foo.js
'./parse',
'./compile',
'./util/escape'
], function (exports) {
//Optionally create a global object
//for apps that just want to use
//<script src="foo.js"> and use
//a global "foo" object to interact.
foo = exports;
});
/** foo/parse.js **/
foo.parse = function () {};
/** foo/render.js **/
foo.render = function () {};
/** foo/util/escape.js **/
foo.escape = function () {};
/** RequireJS optimizer can turn the above into one file. **/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment