Include loads JavaScripts in a First-In-First-Out pattern. Across all browsers it loads files same way that document.write(<script src=' .... '></script>) works in FireFox.
include.controllers(arguments)
Accepts any number of controller names as arguments. Loads each controller at controllers/controllername_controller.js.
// loads controllers/todos_controller.js
include.controllers('todos');
include.functional_tests(arguments)
Accepts any number of functional test names as arguments. Loads each functional test at test/functional/functionaltestname_test.js.
// loads test/functional/calendar_test.js
include.functional_tests('calendar');
include.get_absolute_path() -> String
Returns the current path converted to an absolute path.
include.get_env() -> String
Returns the current environment, either "development", "test", "compress", or "production". Useful for conditional debugging code or production optimizations.
include.get_path() -> String
Returns the current working include path.
include.get_production_name() -> String
Returns the name of the production file.
include.get_production_name() -> String
Returns the name and location of the production file.
include([paths|options ....])
Includes multiple files. Optional .js extension. include takes a list of paths or objects as its arguments.
| Option | Default | Description |
|---|---|---|
| path | undefined | The relative or absolute location of the path to be loaded. Specifying the extension isn't optional if you use this option. You must be specify the full filename, such as "view.js". |
| base62 | false | true for base62 compression on this specific file. |
| shrink_variables | true | true to shrink variables on this specific file. |
include.setup(options)
Configures include. This must be added before the first include.
| Option | Default | Description |
|---|---|---|
| env | 'development' | Describes which mode you are in. This can take 3 values. 'development' mode files load normally. 'compress' mode files load normally, but a new window opens that compresses them. 'production' mode loads a production file. |
| production | '/javascripts/production.js' | The loaction of the production javascript file. |
| base62 | false | true if you want to activate base62 compression. |
| shrink_variables | true | true if you want to shrink variables. |
| remote | false | true if you want to compress for a remote application. |
include.models(arguments)
Accepts any number of model names as arguments. Loads each model at model/modelname.js.
// loads model/todo.js
include.model('todo');
include.plugin(plugin_name)
Loads the JavaScriptMVC plugin with the associated name. Loads the setup file for the plugin, then sets the path back to whatever it was before.
include.plugins(arguments)
Accepts any number of plugin names. Calls include.plugin() for each.
include.resources(arguments)
Accepts any number of file names as arguments. The resources folder is where non-JavaScriptMVC files belong. Loads each file at resources/filename.js.
// loads resources/prototype.js
include.resources('prototype');
include.set_path(path)
Pass in a path name and include will evaluate future paths encountered as relative from this new path.
include.unit_tests(arguments)
Accepts any number of unit test names as arguments. Loads each unit test at test/unit/unittestname_test.js.
// loads test/unit/date_test.js
include.unit_tests('date');
include.view(arguments)
Loads view at views/templatename.ejs.
In compress mode, the view is compiled into a function and placed in the compressed collection of files.
// loads views/list.ejs
include.views('list');
include.views(arguments)
Accepts any number of view template names as arguments. Calls include.view() for each.