Skip to content

testruction/nunjucks-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nunjucks CLI

A simple CLI implementation of a nunjucks with globbing capabilities. (Inspired by handlebars-cli)

Prerequisites

You must make sure you have the following pre-requisites installed:

Using source

git clone https://github.com/testruction/nunjucks-cli.git && cd nunjucks-cli && npm install -g . && njk --help

Using npm

npm install https://github.com/testruction/nodejs-nunjucks-cli.git -g --force

Using package

Or alternatively you can use the latest published package.

Guide

nunjunks/getting-started

Examples

All examples can be run from the root folder for where this repository is checked out.

To see the effects of:

  • One template to one input
  • Many templates to one input
  • One template to many inputs
  • Many templates to many inputs

Please run test/test.sh and navigate to the output in build/.

Help

njk --help

Single transform

njk -t examples/bands.yml.hbs -i examples/bands.yml -o build/single-template-with-single-input-with-file-output/bands.yml
njk -t examples/fruits.yml.hbs -i examples/fruits.yml -o build/single-template-with-single-input-with-file-output/fruits.yml

Single transform (stdout)

njk -t examples/bands.yml.hbs -i examples/bands.yml -s true > build/single-template-with-single-input-with-std-output/bands.yml
njk -t examples/fruits.yml.hbs -i examples/fruits.yml -s true > build/single-template-with-single-input-with-std-output/fruits.yml

Single template transform with glob inputs

njk -t examples/bands.yml.hbs -i examples/**/*.yml -o build/single-template-with-glob-input-with-file-output/bands.yml
njk -t examples/fruits.yml.hbs -i examples/**/*.yml -o build/single-template-with-glob-input-with-file-output/fruits.yml

Single template transform with glob inputs (stdout)

njk -t examples/bands.yml.hbs -i examples/**/*.yml -s true > build/single-template-with-glob-input-with-std-output/bands.yml
njk -t examples/fruits.yml.hbs -i examples/**/*.yml -s true > build/single-template-with-glob-input-with-std-output/fruits.yml

Multiple template transform with single input

njk -t examples/**/*.yml.hbs -i examples/all.yml -o build/glob-template-with-single-input-with-file-output/bands.yml
njk -t examples/**/*.yml.hbs -i examples/all.yml -o build/glob-template-with-single-input-with-file-output/fruits.yml

Multiple template transform with single input (stdout)

njk -t examples/**/*.yml.hbs -i examples/all.yml -s true > build/glob-template-with-single-input-with-std-output/bands.yml
njk -t examples/**/*.yml.hbs -i examples/all.yml -s true > build/glob-template-with-single-input-with-std-output/fruits.yml

Multiple template transform with multiple inputs

njk -t examples/**/*.yml.hbs -i examples/**/*.yml -o build/glob-template-with-glob-input-with-file-output/bands.yml
njk -t examples/**/*.yml.hbs -i examples/**/*.yml -o build/glob-template-with-glob-input-with-file-output/fruits.yml

Multiple template transform with multiple inputs (stdout)

njk -t examples/**/*.yml.hbs -i examples/**/*.yml -s true > build/glob-template-with-glob-input-with-std-output/bands.yml
njk -t examples/**/*.yml.hbs -i examples/**/*.yml -s true > build/glob-template-with-glob-input-with-std-output/fruits.yml

About

A nodejs cli for transforming nunjucks templates using yml files as input

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published