Skip to content
Alex Kit edited this page Jul 10, 2015 · 2 revisions

Objects

mask : object
## Typedefs
AttributeHandler : function

Is called when the builder matches the node by attribute name

StatementHandler : function

Is called when the builder matches the node by tagName

IMaskNode : class
Configuration : object

Configuration Options

IUtilHandler : object

Is called when the builder matches the interpolation. Define process function OR group of node*,attr* functions. The seperation *RenderStart/* is needed for Nodejs rendering - the first part is called on nodejs side, the other one is called on the client.

UtilHandler : function

Is called when the builder matches the interpolation

## mask : object **Kind**: global namespace

mask.TreeWalker

TreeWalker

Kind: static property of mask

TreeWalker.walk(root, visitor)

Visit each mask node

Kind: static method of TreeWalker

Param Type
root MaskNode
visitor TreeWalker~SyncVisitior

TreeWalker.walkAsync(root, visitor, done)

Asynchronous visit each mask node

Kind: static method of TreeWalker

Param Type
root MaskNode
visitor TreeWalker~AsyncVisitior
done function

mask.Dom : object

Dom

Kind: static property of mask

Dom.MaskNode : class

Kind: static property of Dom
Properties

Name Type Default
type type 1
attr object
tagName string
nodes Array.<IMaskNode>
parent IMaskNode
expression string
appendChild function

Dom.TextNode : class

Kind: static property of Dom
Properties

Name Type Default
type type 2
content string | function
parent IMaskNode

mask.render(template, [model], [ctx], [container], [controller]) ⇒ IAppendChild | Node | DocumentFragment

Render the mask template to document fragment or single html node

Kind: static method of mask
Returns: IAppendChild | Node | DocumentFragment - container

Param Type Description
template string | MaskDom Mask string template or Mask Ast to render from.
[model] * Model Object.
[ctx] Object Context can store any additional information, that custom handler may need
[container] IAppendChild Container Html Node where template is rendered into
[controller] Object Component that should own this template

mask.renderAsync() ⇒ Promise

Same to mask.render but returns the promise, which is resolved when all async components are resolved, or is in resolved state, when all components are synchronous. For the parameters doc @see render

Kind: static method of mask
Returns: Promise - Alwats fullfills with IAppendChild|Node|DocumentFragment

mask.parse(template) ⇒ MaskNode

Parse Mask template to the AST tree

Kind: static method of mask

Param Type Description
template string Mask Template

mask.parseHtml(template) ⇒ MaskNode

Parse Html template to the AST tree

Kind: static method of mask

Param Type Description
template string Html Template

mask.build(node, model, ctx, container, controller, children) ⇒ IAppendChild

Kind: static method of mask
Returns: IAppendChild - container

Param Type Description
node MaskNode
model *
ctx object
container IAppendChild
controller object
children Array @out

mask.stringify(node, [opts]) ⇒ string

Serialize Mask AST to the Mask string (@analog to JSON.stringify)

Kind: static method of mask

Param Type Default Description
node MaskNode MaskNode
[opts] object | number Indent count option or an object with options
[opts.indent] number 0 Indent count, 0 for minimization
[opts.minify] bool true
[opts.minimizeAttributes] bool true Remove quotes when possible

mask.run() ⇒ object

Find all <script type="text/mask" data-run='true'> blocks in the page and render each block into the parents container.

The function is automatically renders the blocks <script type="text/mask" data-run='auto'> on DOMContentLoaded event

Kind: static method of mask
Returns: object - Root component

mask.merge(a, b, [owner], [opts]) ⇒ MaskNode

Join two Mask templates or DOM trees

Kind: static method of mask
Returns: MaskNode - New joined Mask DOM tree

Param Type Default Description
a string | MaskNode first template
b string | MaskNode second template
[owner] MaskNode | Component
[opts] object
[opts.extending] bool false Clean the merged tree from all unused placeholders

mask.getHandler(name, [component]) ⇒ IComponent

Get Components constructor from the global repository or the scope

Kind: static method of mask

Param Type Description
name string
[component] object pass a component to look in its scope

mask.getHandlers([component]) ⇒ object

Get all components constructors from the global repository and/or the scope

Kind: static method of mask
Returns: object - All components in an object {name: Ctor}

Param Type Description
[component] object pass a component to look also in its scope

mask.registerHandler(name, component, component, component) ⇒ void

Register a component

Kind: static method of mask

Param Type Description
name string
component object | IComponent
component object Component static definition
component IComponent Components constructor

mask.registerFromTemplate(template, [component], [path]) ⇒ Promise

Register components from a template

Kind: static method of mask
Returns: Promise - - Fullfills when all submodules are resolved and components are registerd

Param Type Description
template string Mask template
[component] object | IComponent Register in the components scope
[path] string Optionally define the path for the template

mask.registerScoped(scopedComponent, name, component) ⇒ void

Register a component

Kind: static method of mask

Param Type Description
scopedComponent object | IComponent Use components scope
name string Name of the component
component object | IComponent Components definition

mask.define() ⇒ void | Promise

Universal component definition, which covers all the cases: simple, scoped, template

    1. (template)
    1. (scopedCompoName, template)
    1. (scopedCtr, template)
    1. (name, Ctor)
    1. (scopedCtr, name, Ctor)
    1. (scopedCompoName, name, Ctor)

Kind: static method of mask

mask.registerAttrHandler(name, [mode], handler) ⇒ void

Register an attribute handler. Any changes can be made to:

  • maskNode's template
  • current element value
  • controller
  • model Note: Attribute wont be set to an element.

Kind: static method of mask

Param Type Description
name string Attribute name to handle
[mode] string Render mode `client
handler AttributeHandler

mask.getAttrHandler(name) ⇒ AttributeHandler

Get attribute handler

Kind: static method of mask

Param Type
name string

mask.registerStatement(name, StatementHandler})

Register a statement handler

Kind: static method of mask

Param Type Description
name string Tag name to handle
StatementHandler} handler

mask.getStatement(name) ⇒ StatementHandler

Get statement handler

Kind: static method of mask

Param Type
name string

mask.config()

Get or Set configuration settings

  • 1 (name)
  • 2 (name, value)
  • 3 (object)

Kind: static method of mask
See: @{link MaskOptions} for all options

mask._

Utils Repository

Kind: static property of mask
Category: Mask Util

Param Type
name string
handler IUtilHandler | UtilHandler

mask.getUtil(name, handler)

Register Util Handler. Template Example: '~[myUtil: value]'

Kind: static method of mask
Category: Mask Util

Param Type
name string
handler mask..IUtilHandler | mask..FUtilHandler

mask.registerUtil(name)

Get the Util Handler

Kind: static method of mask
Category: Mask Util

Param Type
name string

AttributeHandler : function

Is called when the builder matches the node by attribute name

Kind: global typedef

Param Type
node MaskNode
attrValue string
model object
ctx object
element DomNode
parentComponent object

StatementHandler : function

Is called when the builder matches the node by tagName

Kind: global typedef

Param Type Description
node MaskNode
model object
ctx object
container DomNode
parentComponent object
children Array out Fill the array with rendered elements

IMaskNode : class

Kind: global typedef
Properties

Name Type
type number

Configuration : object

Configuration Options

Kind: global typedef

Configuration.preprocessor : object

Style and Script preprocessors

Kind: static property of Configuration

Configuration.style ⇒ string

Transform style before using in style tag

Kind: static property of Configuration

Param Type
style string

Configuration.script ⇒ string

Transform script before using in function,script,event,slot tags

Kind: static property of Configuration

Param Type
source string

Configuration.base

Base path for modules

Kind: static property of Configuration
Default: null

Configuration.getFile ⇒ Promise

Define custom function for getting files content by path

Kind: static property of Configuration

Param Type
path string

Configuration.getScript ⇒ Promise

Define custom function for getting script

Kind: static property of Configuration
Returns: Promise - Fulfill with exports

Param Type
path string

Configuration.buildStyle ⇒ Promise

Define custom function to build/combine styles

Kind: static property of Configuration
Returns: Promise - Fulfill with {string} content

Param Type
path string
options object

Configuration.buildScript ⇒ Promise

Define custom function to build/combine scripts

Kind: static property of Configuration
Returns: Promise - Fulfill with {string} content

Param Type
path string
options object

IUtilHandler : object

Is called when the builder matches the interpolation. Define process function OR group of node*,attr* functions. The seperation *RenderStart/* is needed for Nodejs rendering - the first part is called on nodejs side, the other one is called on the client.

Kind: global abstract typedef
Category: Mask Util
Properties

Name Type Default Description
arguments bool false should parse interpolation string to arguments, otherwise raw string is passed
process UtilHandler
nodeRenderStart function expr, model, ctx, element, controller, attrName
node function expr, model, ctx, element, controller
attr function expr, model, ctx, element, controller, attrName
attrRenderStart function expr, model, ctx, element, controller, attrName

UtilHandler : function

Is called when the builder matches the interpolation

Kind: global abstract typedef
Category: Mask Util

Param Type Description
value string string after the utility name
model object
type "attr" | "node" Current location: text node or attribute
element HTMLNode
name string If the interpolation is in attribute, then this will contain attributes name
Clone this wiki locally