Module: delite/Template

delite/Template

require(["delite/Template"], function (Template) {
  new Template(tree, rootNodeName, createRootNode);
});

Given an AST representation of the template, generates a function that:

  1. generates DOM corresponding to the template
  2. returns an object including a function to be called to update that DOM when widget properties have changed.

The function is available through this.func, i.e.:

var template = new Template(ast);
template.func(document, register);

See the reference documentation for details on the AST format.

Parameters:
Name Type Description
tree Object

AST representing the template.

rootNodeName string

Name of variable for the root node of the tree, typically this.

createRootNode boolean

If true, create node; otherwise assume node exists in variable nodeName.

Source:
Show inherited

Members

<readonly> func :function

Generated function.

Type:
  • function
Source:

<readonly> text :string

Text of the generated function.

Type:
  • string
Source:

Methods

<static> getElement(tag) → {Element}

Return cached reference to Element with given tag name.

Parameters:
Name Type Description
tag string
Source:
Returns:
Type
Element

<static> getProp(tag, attrName) → {string}

Given a tag and attribute name, return the associated property name, or undefined if no such property exists, for example:

  • getProp("div", "tabindex") --> "tabIndex"
  • getProp("div", "role") --> undefined

Note that in order to support SVG, getProp("svg", "class") returns null instead of className.

Parameters:
Name Type Description
tag string

Tag name.

attrName string

Attribute name.

Source:
Returns:
Type
string