Created
May 9, 2012 14:20
-
-
Save sbleon/2644830 to your computer and use it in GitHub Desktop.
Javascript/Coffeescript namespace pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
= require jquery | |
= require namespace | |
= require js_functions | |
= require coffee_functions | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.extend MyApp, { | |
test3: -> | |
alert('test3') | |
test4: -> | |
alert('test4') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.extend(MyApp, { | |
test: function() { | |
alert('test'); | |
} | |
test2: function() { | |
alert('test2'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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