Skip to content

cellsjs/pisco-plugin-nunjucks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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>

About

piscosour plugin for create nunjucks scaffold

Resources

Stars

Watchers

Forks

Packages

No packages published