2.0.0 • Published 7 years ago

wintersmith-nunjucks v2.0.0

Weekly downloads
7
License
BSD-2-Clause
Repository
github
Last release
7 years ago

wintersmith-nunjucks

nunjucks plugin for wintersmith

How to use

  1. Install globally using npm: npm install -g wintersmith-nunjucks
  2. Add to your wintersmith config.json: "plugins": ["wintersmith-nunjucks"]
  3. Create nunjucks templates ending in .html

How to add custom filters

From the nunjucks documentation at http://jlongster.github.io/nunjucks/templating.html#filters:

Filters are essentially functions that can be applied to variables. They are called with a pipe operator (|) and can take arguments.

For more information on how to write customer Filters, take a look at the API documentation page at: http://jlongster.github.io/nunjucks/api#custom-filters

To use customer filters with wintersmith, put the filter in its own file stored in a filters directory. The filename has to be the name of the filter + '.js'.

so if your filter is in './filters/myfirstfilter.js' add a nunjucks section like this to your config.json:

"nunjucks": {
    "filterdir": "filters",
    "filters": ["myfirstfilter"]
}

It will be available in your templates at 'myfirstfilter'

Filters that are already packaged in modules (like for example nunjucks-date) can be loaded by specifying them like this in your config.json, if they export an install-method:

"nunjucks": {
    "filtermodules": "nunjucks-date"
}

this specific filter would then be available as date in your templates.

Autoescaping

As of nunjucks 2 autoescaping was turned on by default. This plugin reverts that since autoescaping is not usually wanted when used in a static site generator. If you want to change behaviour for some reason you can control it with the autoescape option in your config.json.

"nunjucks": {
    "autoescape": true
}
2.0.0

7 years ago

1.1.0

8 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.5.1

10 years ago

0.5.0

10 years ago

0.4.1

10 years ago

0.3.0

10 years ago

0.2.1

11 years ago

0.2.0

11 years ago

0.1.3

11 years ago

0.1.2

11 years ago

0.1.1

12 years ago

0.1.0

12 years ago