Renderer

Renderer

new Renderer()

Source:

Methods

handleNoteNode(node, astNode, data)

Source:

This is a callback to handle note node when Renderering,
override this function, you can handle note node as you like.

Example
// the usage is simliar to handleTextNode
Parameters:
Name Type Description
node obejct

DOMElment || DOMNode

astNode object

The ast expression of this node

data object

the template data

handleTagNode(node, astNode, data)

Source:

This is a callback to handle tag node when Renderering,
override this function, you can handle tag node as you like.

Example
// the usage is simliar to handleTextNode
Parameters:
Name Type Description
node obejct

DOMElment || DOMNode

astNode object

The ast expression of this node

data object

the template data

handleTextNode(node, astNode, data)

Source:

This is a callback to handle text node when Renderering,
override this function, you can handle text node as you like.

Example
// you can use Tpl's overrideRenderer to override this function
var tpl = new Tpl('abcdefg', {
 textTip: 'text handle: '
})
tpl.overrideRenderer('handleTextNode', function (node, astNode, data) {
 let text = astNode.text
 node.nodeValue = data[textTip] + text
})
tpl.parse().Renderer().getDom()[0] // "text handle: abcdefg"
Parameters:
Name Type Description
node obejct

DOMElment || DOMNode

astNode object

The ast expression of this node

data object

the template data

render(ast, data) → {Array}

Source:

Renderer the ast, defined in Renderer.prototype

Parameters:
Name Type Description
ast Array

the ast Array

data Object

the template data

Returns:

the dom Array

Type
Array