pisco-plugin-nunjucks

0.2.1 • Public • Published

This plugin renders a scaffold folder with nunjucks and metalsmith

pisco-plugin-nunjucks - njkRender

let p = this.njkRender(root, from, to, vars);

Where

  • root is the root directory where origin and destination folder are placed,
  • from is the origin folder with the scaffold and nunjucks templates,
  • to is the destination folder,
  • vars is an object with the vars to be replaced and used in the nunjucks templates.

and returns a Promise.

Example:

When the plugin is called like:

  this.njkRender(
      path.resolve('./'),
        'fromPath',
        'toPath',
        { foo: 'meow' })
    .then(
        something();
    )
    .catch( (reason) => {
        console.error(reason);
    });

And exists a file ./fromPath/example.html with the content:

<div>
This is a {{ foo }} cat 
</div>

Then a new file ./toPath/example.html is created:

<div>
This is a meow cat 
</div>

Package Sidebar

Install

npm i pisco-plugin-nunjucks

Weekly Downloads

0

Version

0.2.1

License

Apache-2.0

Last publish

Collaborators

  • cells-developers