Nunjucks engine interface
This module allows Nunjucks templates to be used with DADI Web.
Installation
-
Add this module as a dependency:
npm install web-nunjucks
-
Include it in the
engines
array passed to Web:engines:
Configuration
The following configuration parameters can be added to the global Web config file, under engines.nunjucks
.
paths
Paths required by Nunjucks.
- Format:
Object
- Default:
{ { helpers: 'workspace/utils/helpers' } }
Partials
Filters
To use filters supply the path to your filters in the main Web configuration file:
"engines":
Filters are individual JavaScript files within the specifed directory:
Example: workspace/filters/uppercase.js
module { return input}
Helpers
To use helpers supply the path to your helpers in the main Web configuration file:
"engines":
Helpers are Nunjucks macros stored in individual files within the specifed directory, or all in a single file.
Example:
# Returns the full name and price of the supplied product Usage: renderProduct product # % macro % helper: productname - £ productprice % endmacro %