trucks-transform-tree

Humanize the component tree

Usage no npm install needed!

<script type="module">
  import trucksTransformTree from 'https://cdn.skypack.dev/trucks-transform-tree';
</script>

README

Tree Transform

Humanize the component tree

Converts the component tree to another tree suitable for passing to archy.

Install

npm i trucks-transform-tree --save-dev

For the command line interface see trucks-cli.



Usage

Use the tree key to configure this transform:

const trucks = require('trucks');

trucks(
  {
    files: ['components.html'],
    transforms: ['tree'],
    conf: {
      transforms: {
        tree: {
          label: (tag, id) => {
            return tag + '#' + id; 
          }
        }
      }
    }
  }, (err, state) => {
    if(err) {
      throw err; 
    }
    console.log(state.result.tree.toString());
  }
);

License

MIT


Created by mkdoc on July 18, 2016