rogain-resolve-tree
v0.4.0
Published
Resolve rogain tree with given data into simple dom tree.
Downloads
24
Maintainers
Readme
rogain-resolve-tree
Resolve rogain tree with given data into simple dom tree. The output dom tree is useful for render to string or diffing sets of trees.
Example
import tree from './template.json';
import data from './data.json';
var currentTreeState = resolveTree(tree, data, config);
resolveTree(tree, props, options)
Resolves a rogain tree into a simple dom tree with a given set of properies.
tree
Object in Rogain tree format.
props
Object.
options
options.components
optional rogain-registry
instance. defines components used in resolution.
Output
The output of the resolveTree function will be a basic dom tree.
Input Rogain Template
<Each data={friends} as="friend">
<Friend data={friend} />
</Each>
Friend Component
<h2>{@attrs.data.lastName}, {@attrs.data.firstName}</h2>
Input Data Object
{
friends: [
{ firstName: 'Ben', lastName: 'Forester' },
{ firstName: 'Larry', lastName: 'Forman' },
]
}
Output Tree
[
{ type: 'tag', name: 'h2', children: ['Forester, Ben'] },
{ type: 'tag', name: 'h2', children: ['Forman, Larry'] }
]
Install
With npm do:
npm install rogain-resolve-tree
License
MIT