trucks-transform-usage

Generate component usage examples

Usage no npm install needed!

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

README

Usage Transform

Generate component usage examples

Install

npm i trucks-transform-trim --save-dev

For the command line interface see trucks-cli.

For each component module definition scan the input document for elements matching the component tag name and write them to usage HTML files.



Usage

Use the usage key to configure this transform:

const trucks = require('trucks');

trucks(
  {
    files: ['components.html'],
    transforms: ['usage'],
    usage: {
      main: false,
      files: true
    }
  }, (err, state) => {
    if(err) {
      throw err; 
    }
    console.log(state);
  }
);

API

trim

public trim(state, conf)

Removes leading and trailing whitespace from inline styles and scripts.

When the lines option is given each line is stripped of leading whitespace that matches the pattern regular expression.

Returns map of visitor functions.

  • state Object compiler state.
  • conf Object transform plugin configuration.

Options

  • inline Boolean=true only replace inline elements.
  • lines Boolean=true strip each line.
  • templates Boolean=false also trim template elements.

License

MIT


Created by mkdoc on August 4, 2016