The View uses templates to specify the visible elements. The View accepts Template objects, strings, numbers, or arrays of these.
Template objects capture an XML-like tree of elements. Each Template object has a tag that can be a standard HTML tag string, a published Component string, or a Component class. It also contains any attributes and children associated with each element. Unlike XML, children can be any JavaScipt type.
Template trees are normally built using Template Markup Language (TML).
new Template(tag, props, children)
tag (required)props (optional, default: {}).children (optional, default: [])checkChildTags(tagsAllowed, msg)
Check that the Template object's children array has valid children.
+*?A boolean. True if the Template has the required children. False otherwise.
clone()
Returns a new Template object identical to this one. Only the direct children of the template are copied.
A Template object.
findChildrenByClassName(className, …)
Searches the template tree from this Template object down, for children that have any of the classNames. Returns an array of children that have any of the specified classes.
className (all arguments)An array of Template objects representing any descendant of this Template object having any of the specified CSS classNames.
getChildByTag(tag)
Return the first child that has the specified tag. Only the direct children of the Template object are searched.
tagReturn value A child Template that has a matching tag, or null if not found.
getChildrenByTag(tag)
Return an array of children that have the specified tag. Only the direct children of this Template object are searched.
An array of children that have any of the specified tags.
splitChildrenByTag(tag, ...)
Segregate child templates by tag. The arguments are a set of tags. It returns an array containing arrays. The outer array has an array element for each tag argument, plus one more for children not matching any tag argument. Children with matching tags are placed in the results array element corresponding to the tag position in the arguments. Strings, Numbers, and children that don't correspond to any category are placed in the last result array.
An array of arrays.
toString()
Convert this Template and its children into an XML string.
Note: toString can be used on any TML result, including Template objects, strings, or Numbers.
An XML string.
toText()
Convert this Template's children into a string containing only the text content.
A string.
childrenThe children array that was passed to the constructor, then flattened with blank strings filtered out. If no children were passed, then this is an empty array.
An array containing Template objects and/or any JavaScipt type.
propsThe props object that was passed to the constructor. If no props object was passed, then this is an empty object.
An object.
tagThe tag string or Component class that was passed to the constructor.
A String or Component class.