rogain-resolve-tree

0.4.0 • Public • Published

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.4.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.4.0
    0
  • 0.3.1
    1
  • 0.2.0
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i rogain-resolve-tree

Weekly Downloads

1

Version

0.4.0

License

MIT

Last publish

Collaborators

  • krambuhl