Skip to content
Resolves a rogain tree into a simple dom tree using a json object.
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.babelrc
.gitignore
.jshintrc
.npmignore
LICENSE
README.md
package.json

README.md

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';

const 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 class="friend">{@attrs.data.firstName} {@attrs.data.lastName}</h2>

Input Data Object

{
  friends: [{
    firstName: 'Ben',
    lastName: 'Forester'
  }, {
    firstName: 'Larry',
    lastName: 'Forman'
  }]
}

Output Tree

[{
  type: 'tag',
  name: 'h2',
  attribs: { class: 'friend' },
  children: ['Ben Forester']
}, {
  type: 'tag',
  name: 'h2',
  attribs: { class: 'friend' },
  children: ['Larry Forman']
}]

Install

With npm do:

npm install rogain-resolve-tree

License

MIT

You can’t perform that action at this time.