Needful Program Management
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

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

install

npm i rogain-resolve-tree

Downloadsweekly downloads

2

version

0.4.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability