-
Notifications
You must be signed in to change notification settings - Fork 6
5 API
-
mask :
object
-
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 ofnode*
,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
object
**Kind**: global namespace
-
mask :
object
- .TreeWalker
-
.Dom :
object
-
.render(template, [model], [ctx], [container], [controller]) ⇒
IAppendChild
|Node
|DocumentFragment
-
.renderAsync() ⇒
Promise
-
.parse(template) ⇒
MaskNode
-
.parseHtml(template) ⇒
MaskNode
-
.build(node, model, ctx, container, controller, children) ⇒
IAppendChild
-
.stringify(node, [opts]) ⇒
string
-
.run() ⇒
object
-
.merge(a, b, [owner], [opts]) ⇒
MaskNode
-
.getHandler(name, [component]) ⇒
IComponent
-
.getHandlers([component]) ⇒
object
-
.registerHandler(name, component, component, component) ⇒
void
-
.registerFromTemplate(template, [component], [path]) ⇒
Promise
-
.registerScoped(scopedComponent, name, component) ⇒
void
-
.define() ⇒
void
|Promise
-
.registerAttrHandler(name, [mode], handler) ⇒
void
-
.getAttrHandler(name) ⇒
AttributeHandler
- .registerStatement(name, StatementHandler})
-
.getStatement(name) ⇒
StatementHandler
- .config()
- Mask Util
TreeWalker
Kind: static property of mask
Visit each mask node
Kind: static method of TreeWalker
Param | Type |
---|---|
root | MaskNode |
visitor | TreeWalker~SyncVisitior |
Asynchronous visit each mask node
Kind: static method of TreeWalker
Param | Type |
---|---|
root | MaskNode |
visitor | TreeWalker~AsyncVisitior |
done | function |
Dom
Kind: static property of mask
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 |
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 |
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
Parse Mask template to the AST tree
Kind: static method of mask
Param | Type | Description |
---|---|---|
template | string |
Mask Template |
Parse Html template to the AST tree
Kind: static method of mask
Param | Type | Description |
---|---|---|
template | string |
Html Template |
Kind: static method of mask
Returns: IAppendChild
- container
Param | Type | Description |
---|---|---|
node | MaskNode |
|
model | * |
|
ctx | object |
|
container | IAppendChild |
|
controller | object |
|
children | Array |
@out |
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 |
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
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 |
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 |
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 |
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 |
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 |
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 |
Universal component definition, which covers all the cases: simple, scoped, template
-
- (template)
-
- (scopedCompoName, template)
-
- (scopedCtr, template)
-
- (name, Ctor)
-
- (scopedCtr, name, Ctor)
-
- (scopedCompoName, name, Ctor)
Kind: static method of mask
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 |
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 |
Get or Set configuration settings
- 1
(name)
- 2
(name, value)
- 3
(object)
Kind: static method of mask
See: @{link MaskOptions} for all options
Utils Repository
Kind: static property of mask
Category: Mask Util
Param | Type |
---|---|
name | string |
handler |
IUtilHandler | UtilHandler
|
Register Util Handler. Template Example: '~[myUtil: value]'
Kind: static method of mask
Category: Mask Util
Param | Type |
---|---|
name | string |
handler |
mask..IUtilHandler | mask..FUtilHandler
|
Get the Util Handler
Kind: static method of mask
Category: Mask Util
Param | Type |
---|---|
name | string |
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 |
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 |
Kind: global typedef
Properties
Name | Type |
---|---|
type | number |
Configuration Options
Kind: global typedef
-
Configuration :
object
-
.preprocessor :
object
-
.style ⇒
string
-
.script ⇒
string
- .base
-
.getFile ⇒
Promise
-
.getScript ⇒
Promise
-
.buildStyle ⇒
Promise
-
.buildScript ⇒
Promise
-
.preprocessor :
Style and Script preprocessors
Kind: static property of Configuration
Transform style before using in style
tag
Kind: static property of Configuration
Param | Type |
---|---|
style | string |
Transform script before using in function,script,event,slot
tags
Kind: static property of Configuration
Param | Type |
---|---|
source | string |
Base path for modules
Kind: static property of Configuration
Default: null
Define custom function for getting files content by path
Kind: static property of Configuration
Param | Type |
---|---|
path | string |
Define custom function for getting script
Kind: static property of Configuration
Returns: Promise
- Fulfill with exports
Param | Type |
---|---|
path | string |
Define custom function to build/combine styles
Kind: static property of Configuration
Returns: Promise
- Fulfill with {string} content
Param | Type |
---|---|
path | string |
options | object |
Define custom function to build/combine scripts
Kind: static property of Configuration
Returns: Promise
- Fulfill with {string} content
Param | Type |
---|---|
path | string |
options | 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 |
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 |