Skip to content

Instantly share code, notes, and snippets.

@sbleon
Created May 9, 2012 14:20
Show Gist options
  • Save sbleon/2644830 to your computer and use it in GitHub Desktop.
Save sbleon/2644830 to your computer and use it in GitHub Desktop.
Javascript/Coffeescript namespace pattern
/*
= require jquery
= require namespace
= require js_functions
= require coffee_functions
*/
$.extend MyApp, {
test3: ->
alert('test3')
test4: ->
alert('test4')
}
$.extend(MyApp, {
test: function() {
alert('test');
}
test2: function() {
alert('test2');
}
});
// Create a top-level namespace that we can extend and refer to later.
var MyApp = {};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment