Require.js example.
Alogos are still BROKEN. I'm deploying them here for testing.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
//Set requireJS settings for coffee script plugin.
|
||||
requirejs.config({
|
||||
baseUrl:'../', //relative to this file
|
||||
paths: { //relative to baseUrl
|
||||
cs: 'requirejs/cs',
|
||||
'coffee-script': 'requirejs/coffee-script'
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//Require files we need.
|
||||
//There are may ways to require files. Some of them just dump\run the file as it is within WINDOW scope. Some assign modules to given variables (like node.js does) and a few more.
|
||||
//Main difference is order in which your code gets executed. Read more about concept at http://requirejs.org/ there are a lot of problems solved by require.js.
|
||||
|
||||
|
||||
//Load array of modules (in this case 'app/module') into the variables (in this case module). "cs!" - means this file has to be parsed by cs plugin first.
|
||||
requirejs(['cs!app/module'], function (module) {
|
||||
//foo() is defined within module.coffee. We can use it within this callback.
|
||||
module.foo('Hello!')
|
||||
});
|
||||
Reference in New Issue
Block a user