runas-plugin-nunjucks
runas plugin for templating with metalsmith and nunjucks
Last updated 3 years ago by apecr .
Apache-2.0 · Bugs · Original npm · Tarball · package.json
$ cnpm install runas-plugin-nunjucks 
SYNC missed versions from official npm registry.

This plugin renders a scaffold folder with nunjucks and metalsmith

runas-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>

Current Tags

  • 0.3.1                                ...           latest (3 years ago)

2 Versions

  • 0.3.1                                ...           3 years ago
  • 0.3.0                                ...           3 years ago
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 2
Dependencies (4)
Dev Dependencies (4)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |