Include

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.

controllers, functional_tests, get_absolute_path, get_env, get_path, get_production_name, include, models, plugin, plugins, resources, setup, set_path, unit_tests, view, views

Related

MVC

Methods

controllers

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');
test

functional_tests

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');

get_absolute_path

include.get_absolute_path() -> String

Returns the current path converted to an absolute path.

get_env

include.get_env() -> String

Returns the current environment, either "development", "test", "compress", or "production". Useful for conditional debugging code or production optimizations.

get_path

include.get_path() -> String

Returns the current working include path.

get_production_name

include.get_production_name() -> String

Returns the name of the production file.

get_production_name

include.get_production_name() -> String

Returns the name and location of the production file.

include

include([paths|options ....])

Includes multiple files. Optional .js extension. include takes a list of paths or objects as its arguments.

options

OptionDefaultDescription
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.

setup

include.setup(options)

Configures include. This must be added before the first include.

options

OptionDefaultDescription
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.

models

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');

plugin

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.

- The name of the plugin to be loaded.

plugins

include.plugins(arguments)

Accepts any number of plugin names. Calls include.plugin() for each.

resources

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');

set_path

include.set_path(path)

Pass in a path name and include will evaluate future paths encountered as relative from this new path.

- The path to set to.
test

unit_tests

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');
view

view

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');
view

views

include.views(arguments)

Accepts any number of view template names as arguments. Calls include.view() for each.