Last active
December 21, 2015 21:29
-
-
Save designeng/6368563 to your computer and use it in GitHub Desktop.
Module loader
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
define [], () -> | |
class mLoader | |
modules: ["modules/footer", "modules/header"] | |
init: () -> | |
for m in @modules | |
moduleShortName = m.split("/")[1] + "Module" | |
modulePath = m + "/index" | |
define moduleShortName, [modulePath], (mod) -> | |
return mod | |
############ usage ################ | |
require ["footerModule"], (fm) -> | |
console.log fm.init() | |
require ["headerModule"], (fm) -> | |
console.log fm.init() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment