Documentation ¶
Overview ¶
Copyright 2014 dong<ddliuhb@gmail.com>. Licensed under the MIT license.
Motto - Modular Javascript environment.
Copyright 2014 dong<ddliuhb@gmail.com>. Licensed under the MIT license.
Motto - Modular Javascript environment.
Copyright 2014 dong<ddliuhb@gmail.com>. Licensed under the MIT license.
Motto - Modular Javascript environment.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindFileModule ¶
Find a file module by name.
If name starts with "." or "/", we search the module in the according locations (name and name.js and name.json).
Otherwise we search the module in the "node_modules" sub-directory of "pwd" and "paths"
It basicly follows the rules of Node.js module api: http://nodejs.org/api/modules.html
Types ¶
type ModuleLoader ¶
ModuleLoader is declared to load a module.
func CreateLoaderFromFile ¶
func CreateLoaderFromFile(filename string) ModuleLoader
Create module loader from javascript file.
Filename can be a javascript file or a json file.
func CreateLoaderFromSource ¶
func CreateLoaderFromSource(source, pwd string) ModuleLoader
Create module loader from javascript source code.
When the loader is called, the javascript source is executed in Motto.
"pwd" indicates current working directory, which might be used to search for modules.
type Motto ¶
type Motto struct { // Motto is based on otto *otto.Otto // contains filtered or unexported fields }
Motto is modular vm environment
func (*Motto) AddModule ¶
func (m *Motto) AddModule(id string, l ModuleLoader)
AddModule registers a new module to current vm.