Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeremyben/nunjucks-cli
Simple Nunjucks CLI wrapper and templates watcher
https://github.com/jeremyben/nunjucks-cli
cli npm nunjucks template-engine
Last synced: 2 months ago
JSON representation
Simple Nunjucks CLI wrapper and templates watcher
- Host: GitHub
- URL: https://github.com/jeremyben/nunjucks-cli
- Owner: jeremyben
- License: mit
- Created: 2016-05-02T13:46:28.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-03T14:45:56.000Z (about 2 years ago)
- Last Synced: 2024-09-26T20:45:55.659Z (3 months ago)
- Topics: cli, npm, nunjucks, template-engine
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/nunjucks-cli
- Size: 106 KB
- Stars: 27
- Watchers: 7
- Forks: 18
- Open Issues: 19
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Nunjucks-cli
Simple Nunjucks CLI Wrapper and templates watcher, to generate static HTML files.
## Installation
```bash
npm i -D nunjucks-cli # local
npm i -g nunjucks-cli # global
```## Usage
```bash
nunjucks [context] [options]
```_For convenience, `process.env` object is added to the context as `env`._
#### Basic examples
```bash
nunjucks foo.tpl data.json
```Compiles `foo.tpl` to `foo.html` with data from `data.json` (and variables from `process.env` as `env`).
```bash
nunjucks **/*.tpl
```Compiles all `.tpl` files (including subdirectories), except the ones starting by `_` (so you can use them as layouts).
## Options
### `--path `
`-p `
Path where the templates live. Default to the current working directory.
See### `--out `
`-o `
Output directory.
### `--watch`
`-w`
Allows to keep track of file changes and render accordingly (except files starting by `_`).
### `--extension `
`-e `
Extension for rendered files. Defaults to `html`.
### `--options `
`-O `
Takes a json file as Nunjucks options. Defaults are :
```json
trimBlocks: true,
lstripBlocks: true,
noCache: true
```See
#### Advanced examples
```bash
nunjucks foo.tpl -p src -o dist -O nj.json
```Compiles `src/foo.tpl` to `dist/foo.html`, with `nj.json` as nunjucks environnement options.
```bash
nunjucks *.tpl data.json -w -p src
```Compiles all `.tpl` files (except ones starting with `_`) in the `src` folder to the current working directory, with `data.json` as metadata, and keeps running in the background for files changes.