├── test
├── fixtures
│ └── list.njk
└── test.js
├── .gitattributes
├── .editorconfig
├── .travis.yml
├── .gitignore
├── LICENSE
├── index.js
├── package.json
├── .verb.md
├── .eslintrc.json
└── README.md
/test/fixtures/list.njk:
--------------------------------------------------------------------------------
1 |
{% for item in list %}
2 | - {{item}}
{% endfor %}
3 |
4 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Enforce Unix newlines
2 | * text eol=lf
3 |
4 | # binaries
5 | *.ai binary
6 | *.psd binary
7 | *.jpg binary
8 | *.gif binary
9 | *.png binary
10 | *.jpeg binary
11 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 2
6 | charset = utf-8
7 | trim_trailing_whitespace = true
8 | insert_final_newline = true
9 |
10 | [*.md]
11 | trim_trailing_whitespace = false
12 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - "5"
5 | - "4"
6 | - "0.12"
7 | - "0.10"
8 | matrix:
9 | fast_finish: true
10 | allow_failures:
11 | - node_js: "4"
12 | - node_js: "0.10"
13 | - node_js: "0.12"
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # always ignore files
2 | *.DS_Store
3 | *.sublime-*
4 |
5 | # test related, or directories generated by tests
6 | test/actual
7 | actual
8 | coverage
9 |
10 | # npm
11 | node_modules
12 | npm-debug.log
13 |
14 | # misc
15 | _gh_pages
16 | benchmark
17 | bower_components
18 | vendor
19 | temp
20 | tmp
21 | TODO.md
22 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016, Jon Schlinkert.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var isValid = require('is-valid-app');
4 | var merge = require('mixin-deep');
5 |
6 | module.exports = function(config) {
7 | return function(app) {
8 | if (!isValid(app, 'assemble-nunjucks', ['app', 'collection'])) return;
9 |
10 | var opts = merge({}, this.options, config);
11 | var engine = opts.nunjucks || require('engine-nunjucks');
12 | engine.lazyConfigure(opts);
13 | app.engine('njk', engine);
14 |
15 | var asyncHelpers = app.asyncHelpers;
16 | var asyncHelper = app.asyncHelper;
17 | var helpers = app.helpers;
18 | var helper = app.helper;
19 |
20 | function redefine(name, fn) {
21 | return function() {
22 | if (typeof fn === 'undefined') {
23 | return engine[name].apply(engine, arguments);
24 | }
25 | this[name].apply(this, arguments);
26 | return fn.apply(this, arguments);
27 | };
28 | }
29 |
30 | app.define({
31 | helpers: redefine('addFilters', helpers),
32 | helper: redefine('addFilter', helper),
33 |
34 | asyncHelpers: redefine('asyncFilters', asyncHelpers),
35 | asyncHelper: redefine('asyncFilter', asyncHelper),
36 |
37 | addFilters: redefine('addFilters'),
38 | addFilter: redefine('addFilter'),
39 |
40 | asyncFilters: redefine('asyncFilters'),
41 | asyncFilter: redefine('asyncFilter')
42 | });
43 | };
44 | };
45 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "assemble-nunjucks",
3 | "description": "Adds nunjucks support to assemble, with some assemble-specific conveniences.",
4 | "version": "0.1.3",
5 | "homepage": "https://github.com/assemble/assemble-nunjucks",
6 | "author": "Jon Schlinkert (https://github.com/jonschlinkert)",
7 | "repository": "assemble/assemble-nunjucks",
8 | "bugs": {
9 | "url": "https://github.com/assemble/assemble-nunjucks/issues"
10 | },
11 | "license": "MIT",
12 | "engines": {
13 | "node": ">=0.10.0"
14 | },
15 | "scripts": {
16 | "test": "mocha"
17 | },
18 | "keywords": [
19 | "assemble",
20 | "nunjucks"
21 | ],
22 | "dependencies": {
23 | "engine-nunjucks": "^0.1.1",
24 | "is-valid-app": "^0.2.0",
25 | "mixin-deep": "^1.1.3"
26 | },
27 | "devDependencies": {
28 | "assemble": "^0.16.1",
29 | "gulp-format-md": "^0.1.9",
30 | "mocha": "^2.5.3"
31 | },
32 | "verb": {
33 | "toc": false,
34 | "layout": "common-minimal",
35 | "tasks": [
36 | "readme"
37 | ],
38 | "plugins": [
39 | "gulp-format-md"
40 | ],
41 | "related": {
42 | "list": [
43 | "engine-nunjucks",
44 | "generate",
45 | "update"
46 | ]
47 | },
48 | "reflinks": [
49 | "assemble",
50 | "engine-nunjucks",
51 | "nunjucks"
52 | ],
53 | "lint": {
54 | "reflinks": true
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/.verb.md:
--------------------------------------------------------------------------------
1 | ## Usage
2 |
3 | Add [nunjucks][] support to [assemble][]:
4 |
5 | ```js
6 | var engine = require('{%= name %}');
7 | var assemble = require('assemble');
8 | app.use(engine());
9 | ```
10 |
11 | ### Examples
12 |
13 | Use with `.render`
14 |
15 | ```js
16 | app.page({path: 'foo.njk', contents: 'this is \{{name}}'});
17 |
18 | // render a view
19 | app.render('foo.njk', {name: 'Foo'}, function(err, res) {
20 | console.log(res.contents.toString());
21 | //=> 'this is Foo'
22 | });
23 | ```
24 |
25 | Use with `.renderFile`
26 |
27 | ```js
28 | app.src('*.njk')
29 | .pipe(app.renderFile())
30 | .on('data', function(file) {
31 | console.log(file.contents.toString());
32 | //=> 'this is Foo'
33 | });
34 | ```
35 |
36 | ## What does this do?
37 |
38 | Adds support for [nunjucks][]
39 |
40 | - [rendering](#engine)
41 | - [filters support](#filters)
42 | - [async filters support](#async-filters)
43 |
44 |
45 | Note that you can pass your own [env][] on the options, so you can work directly with the [Nunjucks API][api] if you need to do something that isn't listed here.
46 |
47 | Pull requests are also welcome!
48 |
49 | ### Engine
50 |
51 | Registers [engine-nunjucks][] to the `njk` [extension][ext].
52 |
53 | This means that assemble will automatically use this engine to render templates with the extension `.njk`.
54 | To force assemble to use this engine for rendering all templates, do:
55 |
56 | ```js
57 | app.option('engine', 'njk');
58 | ```
59 |
60 | ### Filters
61 |
62 | Allows you to register a [nunjucks filter][filters] using:
63 |
64 | ```js
65 | app.helper('foo', function(str) {
66 | // do stuff to str
67 | return str;
68 | });
69 | // or
70 | app.addFilter('foo', function(str) {
71 | // do stuff to str
72 | return str;
73 | });
74 | ```
75 |
76 | Register multiple filters with:
77 |
78 | ```js
79 | app.helpers({
80 | foo: function() {},
81 | bar: function() {},
82 | baz: function() {}
83 | });
84 | // or
85 | app.addFilters({
86 | foo: function() {},
87 | bar: function() {},
88 | baz: function() {}
89 | });
90 | ```
91 |
92 | ### Async Filters
93 |
94 | Allows you to register an [async nunjucks filter][async] using:
95 |
96 | ```js
97 | app.asyncHelper('foo', function(str) {
98 | // do stuff to str
99 | return str;
100 | });
101 | // or
102 | app.asyncAddFilter('foo', function(str) {
103 | // do stuff to str
104 | return str;
105 | });
106 | ```
107 |
108 | Register multiple filters with:
109 |
110 | ```js
111 | app.asyncHelpers({
112 | foo: function() {},
113 | bar: function() {},
114 | baz: function() {}
115 | });
116 | // or
117 | app.asyncAddFilters({
118 | foo: function() {},
119 | bar: function() {},
120 | baz: function() {}
121 | });
122 | ```
123 |
124 | ## Customization
125 |
126 | Optionally pass your own `nunjucks` (module):
127 |
128 | ```js
129 | app.use(engine({nunjucks: require('nunjucks')}));
130 | ```
131 |
132 | Optionally pass your own `env`:
133 |
134 | ```js
135 | var nunjucks = require('nunjucks');
136 | var env = new nunjucks.Environment();
137 | app.use(engine({env: env}));
138 | ```
139 |
140 |
141 | [ext]: http://mozilla.github.io/nunjucks/templating.html#file-extensions
142 | [filters]: http://mozilla.github.io/nunjucks/templating.html#filters
143 | [async]: http://mozilla.github.io/nunjucks/api.html#asynchronous-support
144 | [env]: http://mozilla.github.io/nunjucks/api.html#environment
145 | [api]: http://mozilla.github.io/nunjucks/api.html
146 |
--------------------------------------------------------------------------------
/test/test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | require('mocha');
4 | var fs = require('fs');
5 | var path = require('path');
6 | var assert = require('assert');
7 | var assemble = require('assemble');
8 | var engine = require('..');
9 | var app;
10 |
11 | var fixtures = path.resolve.bind(path, __dirname, 'fixtures');
12 | var fixture = fixtures('list.njk');
13 | var str = fs.readFileSync(fixture, 'utf-8');
14 | var locals = {
15 | list: ['alpha', 'beta', 'gamma']
16 | };
17 | var expected = [
18 | '',
19 | ' - alpha
',
20 | ' - beta
',
21 | ' - gamma
',
22 | '
',
23 | ''
24 | ].join('\n');
25 |
26 | describe('assemble', function() {
27 | beforeEach(function() {
28 | app = assemble();
29 | app.use(engine());
30 | app.option('engine', 'njk');
31 | app.create('pages');
32 | app.page({path: 'list.njk', contents: str});
33 | });
34 |
35 | describe('rendering', function() {
36 | it('should render a view with `.render`', function(cb) {
37 | app.render('list.njk', locals, function(err, res) {
38 | if (err) return cb(err);
39 | assert(res);
40 | assert(res.content);
41 | assert.equal(res.content.trim(), expected.trim());
42 | cb();
43 | });
44 | });
45 |
46 | it('should work directly with views', function(cb) {
47 | var view = app.page({path: 'list.njk', contents: str});;
48 | app.render(view, locals, function(err, res) {
49 | if (err) return cb(err);
50 | assert(res);
51 | assert(res.content);
52 | assert.equal(res.content.trim(), expected.trim());
53 | cb();
54 | });
55 | });
56 |
57 | it('should work with layouts', function(cb) {
58 | var base = app.layout({path: 'base.njk', contents: 'foo{% body %}bar'});
59 | var view = app.page({path: 'list.njk', contents: str, layout: 'base'});;
60 | app.render(view, locals, function(err, res) {
61 | if (err) return cb(err);
62 | assert(res);
63 | assert(res.content);
64 | assert.equal(res.content.trim(), 'foo' + expected.trim() + '\nbar');
65 | cb();
66 | });
67 | });
68 |
69 | it('should work with assemble `.renderFile`', function(cb) {
70 | var files = [];
71 | app.src('./test/fixtures/list.njk')
72 | .pipe(app.renderFile(locals))
73 | .on('error', cb)
74 | .on('data', function(file) {
75 | files.push(file);
76 | })
77 | .on('end', function() {
78 | assert(files[0]);
79 | assert(files[0].path);
80 | assert(files[0].contents);
81 | assert.equal(String(files[0].contents), expected);
82 | cb();
83 | });
84 | });
85 | });
86 |
87 | describe('.addFilter', function() {
88 | it('should add a filter', function(cb) {
89 | app.addFilter('foo', function(str) {
90 | return 'foo' + str;
91 | });
92 |
93 | var view = app.view({path: 'abc', content: 'bar {{title | foo}}'});
94 | app.render(view, {title: 'zzz'}, function(err, res) {
95 | if (err) return cb(err);
96 | assert.equal(res.contents.toString(), 'bar foozzz');
97 | cb();
98 | });
99 | });
100 |
101 | it('should work with `.helper`', function(cb) {
102 | app.helper('foo', function(str) {
103 | return 'foo' + str;
104 | });
105 |
106 | var view = app.view({path: 'abc', content: 'bar {{title | foo}}'});
107 | app.render(view, {title: 'zzz'}, function(err, res) {
108 | if (err) return cb(err);
109 | assert.equal(res.contents.toString(), 'bar foozzz');
110 | cb();
111 | });
112 | });
113 | });
114 |
115 | describe('.addFilters', function() {
116 | it('should add multiple filters', function(cb) {
117 | app.addFilters({
118 | foo: function(str) {
119 | return 'foo' + str;
120 | },
121 | bar: function(str) {
122 | return 'bar' + str;
123 | }
124 | });
125 |
126 | var one = app.view({path: 'one', content: 'one {{title | foo}}'});
127 | var two = app.view({path: 'two', content: 'two {{title | bar}}'});
128 |
129 | app.render(one, {title: 'zzz'}, function(err, res) {
130 | if (err) return cb(err);
131 | assert.equal(res.contents.toString(), 'one foozzz');
132 |
133 | app.render(two, {title: 'zzz'}, function(err, res) {
134 | if (err) return cb(err);
135 | assert.equal(res.contents.toString(), 'two barzzz');
136 | cb();
137 | });
138 | });
139 | });
140 |
141 | it('should work with `.helpers`', function(cb) {
142 | app.helpers({
143 | www: function(str) {
144 | return 'www' + str;
145 | },
146 | zzz: function(str) {
147 | return 'zzz' + str;
148 | }
149 | });
150 |
151 | var one = app.view({path: 'one', content: 'one {{title | www}}'});
152 | var two = app.view({path: 'two', content: 'two {{title | zzz}}'});
153 |
154 | app.render(one, {title: 'zzz'}, function(err, res) {
155 | if (err) return cb(err);
156 | assert.equal(res.contents.toString(), 'one wwwzzz');
157 |
158 | app.render(two, {title: 'zzz'}, function(err, res) {
159 | if (err) return cb(err);
160 | assert.equal(res.contents.toString(), 'two zzzzzz');
161 | cb();
162 | });
163 | });
164 | });
165 | });
166 | });
167 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "ecmaFeatures": {
3 | "modules": true,
4 | "experimentalObjectRestSpread": true
5 | },
6 | "env": {
7 | "browser": false,
8 | "es6": true,
9 | "node": true,
10 | "mocha": true
11 | },
12 | "globals": {
13 | "document": false,
14 | "navigator": false,
15 | "window": false
16 | },
17 | "rules": {
18 | "accessor-pairs": 2,
19 | "arrow-spacing": [
20 | 2,
21 | {
22 | "before": true,
23 | "after": true
24 | }
25 | ],
26 | "block-spacing": [
27 | 2,
28 | "always"
29 | ],
30 | "brace-style": [
31 | 2,
32 | "1tbs",
33 | {
34 | "allowSingleLine": true
35 | }
36 | ],
37 | "comma-dangle": [
38 | 2,
39 | "never"
40 | ],
41 | "comma-spacing": [
42 | 2,
43 | {
44 | "before": false,
45 | "after": true
46 | }
47 | ],
48 | "comma-style": [
49 | 2,
50 | "last"
51 | ],
52 | "constructor-super": 2,
53 | "curly": [
54 | 2,
55 | "multi-line"
56 | ],
57 | "dot-location": [
58 | 2,
59 | "property"
60 | ],
61 | "eol-last": 2,
62 | "eqeqeq": [
63 | 2,
64 | "allow-null"
65 | ],
66 | "generator-star-spacing": [
67 | 2,
68 | {
69 | "before": true,
70 | "after": true
71 | }
72 | ],
73 | "handle-callback-err": [
74 | 2,
75 | "^(err|error)$"
76 | ],
77 | "indent": [
78 | 2,
79 | 2,
80 | {
81 | "SwitchCase": 1
82 | }
83 | ],
84 | "key-spacing": [
85 | 2,
86 | {
87 | "beforeColon": false,
88 | "afterColon": true
89 | }
90 | ],
91 | "keyword-spacing": [
92 | 2,
93 | {
94 | "before": true,
95 | "after": true
96 | }
97 | ],
98 | "new-cap": [
99 | 2,
100 | {
101 | "newIsCap": true,
102 | "capIsNew": false
103 | }
104 | ],
105 | "new-parens": 2,
106 | "no-array-constructor": 2,
107 | "no-caller": 2,
108 | "no-class-assign": 2,
109 | "no-cond-assign": 2,
110 | "no-const-assign": 2,
111 | "no-control-regex": 2,
112 | "no-debugger": 2,
113 | "no-delete-var": 2,
114 | "no-dupe-args": 2,
115 | "no-dupe-class-members": 2,
116 | "no-dupe-keys": 2,
117 | "no-duplicate-case": 2,
118 | "no-empty-character-class": 2,
119 | "no-eval": 2,
120 | "no-ex-assign": 2,
121 | "no-extend-native": 2,
122 | "no-extra-bind": 2,
123 | "no-extra-boolean-cast": 2,
124 | "no-extra-parens": [
125 | 2,
126 | "functions"
127 | ],
128 | "no-fallthrough": 2,
129 | "no-floating-decimal": 2,
130 | "no-func-assign": 2,
131 | "no-implied-eval": 2,
132 | "no-inner-declarations": [
133 | 2,
134 | "functions"
135 | ],
136 | "no-invalid-regexp": 2,
137 | "no-irregular-whitespace": 2,
138 | "no-iterator": 2,
139 | "no-label-var": 2,
140 | "no-labels": 2,
141 | "no-lone-blocks": 2,
142 | "no-mixed-spaces-and-tabs": 2,
143 | "no-multi-spaces": 2,
144 | "no-multi-str": 2,
145 | "no-multiple-empty-lines": [
146 | 2,
147 | {
148 | "max": 1
149 | }
150 | ],
151 | "no-native-reassign": 0,
152 | "no-negated-in-lhs": 2,
153 | "no-new": 2,
154 | "no-new-func": 2,
155 | "no-new-object": 2,
156 | "no-new-require": 2,
157 | "no-new-wrappers": 2,
158 | "no-obj-calls": 2,
159 | "no-octal": 2,
160 | "no-octal-escape": 2,
161 | "no-proto": 0,
162 | "no-redeclare": 2,
163 | "no-regex-spaces": 2,
164 | "no-return-assign": 2,
165 | "no-self-compare": 2,
166 | "no-sequences": 2,
167 | "no-shadow-restricted-names": 2,
168 | "no-spaced-func": 2,
169 | "no-sparse-arrays": 2,
170 | "no-this-before-super": 2,
171 | "no-throw-literal": 2,
172 | "no-trailing-spaces": 0,
173 | "no-undef": 2,
174 | "no-undef-init": 2,
175 | "no-unexpected-multiline": 2,
176 | "no-unneeded-ternary": [
177 | 2,
178 | {
179 | "defaultAssignment": false
180 | }
181 | ],
182 | "no-unreachable": 2,
183 | "no-unused-vars": [
184 | 2,
185 | {
186 | "vars": "all",
187 | "args": "none"
188 | }
189 | ],
190 | "no-useless-call": 0,
191 | "no-with": 2,
192 | "one-var": [
193 | 0,
194 | {
195 | "initialized": "never"
196 | }
197 | ],
198 | "operator-linebreak": [
199 | 0,
200 | "after",
201 | {
202 | "overrides": {
203 | "?": "before",
204 | ":": "before"
205 | }
206 | }
207 | ],
208 | "padded-blocks": [
209 | 0,
210 | "never"
211 | ],
212 | "quotes": [
213 | 2,
214 | "single",
215 | "avoid-escape"
216 | ],
217 | "radix": 2,
218 | "semi": [
219 | 2,
220 | "always"
221 | ],
222 | "semi-spacing": [
223 | 2,
224 | {
225 | "before": false,
226 | "after": true
227 | }
228 | ],
229 | "space-before-blocks": [
230 | 2,
231 | "always"
232 | ],
233 | "space-before-function-paren": [
234 | 2,
235 | "never"
236 | ],
237 | "space-in-parens": [
238 | 2,
239 | "never"
240 | ],
241 | "space-infix-ops": 2,
242 | "space-unary-ops": [
243 | 2,
244 | {
245 | "words": true,
246 | "nonwords": false
247 | }
248 | ],
249 | "spaced-comment": [
250 | 0,
251 | "always",
252 | {
253 | "markers": [
254 | "global",
255 | "globals",
256 | "eslint",
257 | "eslint-disable",
258 | "*package",
259 | "!",
260 | ","
261 | ]
262 | }
263 | ],
264 | "use-isnan": 2,
265 | "valid-typeof": 2,
266 | "wrap-iife": [
267 | 2,
268 | "any"
269 | ],
270 | "yoda": [
271 | 2,
272 | "never"
273 | ]
274 | }
275 | }
276 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # assemble-nunjucks [](https://www.npmjs.com/package/assemble-nunjucks) [](https://npmjs.org/package/assemble-nunjucks) [](https://travis-ci.org/assemble/assemble-nunjucks)
2 |
3 | Adds nunjucks support to assemble, with some assemble-specific conveniences.
4 |
5 | ## Usage
6 |
7 | Add [nunjucks](https://github.com/mozilla/nunjucks) support to [assemble](https://github.com/assemble/assemble):
8 |
9 | ```js
10 | var engine = require('assemble-nunjucks');
11 | var assemble = require('assemble');
12 | app.use(engine());
13 | ```
14 |
15 | ### Examples
16 |
17 | Use with `.render`
18 |
19 | ```js
20 | app.page({path: 'foo.njk', contents: 'this is {{name}}'});
21 |
22 | // render a view
23 | app.render('foo.njk', {name: 'Foo'}, function(err, res) {
24 | console.log(res.contents.toString());
25 | //=> 'this is Foo'
26 | });
27 | ```
28 |
29 | Use with `.renderFile`
30 |
31 | ```js
32 | app.src('*.njk')
33 | .pipe(app.renderFile())
34 | .on('data', function(file) {
35 | console.log(file.contents.toString());
36 | //=> 'this is Foo'
37 | });
38 | ```
39 |
40 | ## What does this do?
41 |
42 | Adds support for [nunjucks](https://github.com/mozilla/nunjucks)
43 |
44 | * [rendering](#engine)
45 | * [filters support](#filters)
46 | * [async filters support](#async-filters)
47 |
48 | Note that you can pass your own [env](http://mozilla.github.io/nunjucks/api.html#environment) on the options, so you can work directly with the [Nunjucks API](http://mozilla.github.io/nunjucks/api.html) if you need to do something that isn't listed here.
49 |
50 | Pull requests are also welcome!
51 |
52 | ### Engine
53 |
54 | Registers [engine-nunjucks](https://github.com/jonschlinkert/engine-nunjucks) to the `njk` [extension](http://mozilla.github.io/nunjucks/templating.html#file-extensions).
55 |
56 | This means that assemble will automatically use this engine to render templates with the extension `.njk`.
57 | To force assemble to use this engine for rendering all templates, do:
58 |
59 | ```js
60 | app.option('engine', 'njk');
61 | ```
62 |
63 | ### Filters
64 |
65 | Allows you to register a [nunjucks filter](http://mozilla.github.io/nunjucks/templating.html#filters) using:
66 |
67 | ```js
68 | app.helper('foo', function(str) {
69 | // do stuff to str
70 | return str;
71 | });
72 | // or
73 | app.addFilter('foo', function(str) {
74 | // do stuff to str
75 | return str;
76 | });
77 | ```
78 |
79 | Register multiple filters with:
80 |
81 | ```js
82 | app.helpers({
83 | foo: function() {},
84 | bar: function() {},
85 | baz: function() {}
86 | });
87 | // or
88 | app.addFilters({
89 | foo: function() {},
90 | bar: function() {},
91 | baz: function() {}
92 | });
93 | ```
94 |
95 | ### Async Filters
96 |
97 | Allows you to register an [async nunjucks filter](http://mozilla.github.io/nunjucks/api.html#asynchronous-support) using:
98 |
99 | ```js
100 | app.asyncHelper('foo', function(str) {
101 | // do stuff to str
102 | return str;
103 | });
104 | // or
105 | app.asyncAddFilter('foo', function(str) {
106 | // do stuff to str
107 | return str;
108 | });
109 | ```
110 |
111 | Register multiple filters with:
112 |
113 | ```js
114 | app.asyncHelpers({
115 | foo: function() {},
116 | bar: function() {},
117 | baz: function() {}
118 | });
119 | // or
120 | app.asyncAddFilters({
121 | foo: function() {},
122 | bar: function() {},
123 | baz: function() {}
124 | });
125 | ```
126 |
127 | ## Customization
128 |
129 | Optionally pass your own `nunjucks` (module):
130 |
131 | ```js
132 | app.use(engine({nunjucks: require('nunjucks')}));
133 | ```
134 |
135 | Optionally pass your own `env`:
136 |
137 | ```js
138 | var nunjucks = require('nunjucks');
139 | var env = new nunjucks.Environment();
140 | app.use(engine({env: env}));
141 | ```
142 |
143 | ## About
144 |
145 | ### Related projects
146 |
147 | * [engine-nunjucks](https://www.npmjs.com/package/engine-nunjucks): More comprehensive consolidate-style engine support for nunjucks. Should work with express, assemble, verb, generate, update… [more](https://github.com/jonschlinkert/engine-nunjucks) | [homepage](https://github.com/jonschlinkert/engine-nunjucks "More comprehensive consolidate-style engine support for nunjucks. Should work with express, assemble, verb, generate, update, and any other app that follows consolidate conventions.")
148 | * [generate](https://www.npmjs.com/package/generate): Command line tool and developer framework for scaffolding out new GitHub projects. Generate offers the… [more](https://github.com/generate/generate) | [homepage](https://github.com/generate/generate "Command line tool and developer framework for scaffolding out new GitHub projects. Generate offers the robustness and configurability of Yeoman, the expressiveness and simplicity of Slush, and more powerful flow control and composability than either.")
149 | * [update](https://www.npmjs.com/package/update): Be scalable! Update is a new, open source developer framework and CLI for automating updates… [more](https://github.com/update/update) | [homepage](https://github.com/update/update "Be scalable! Update is a new, open source developer framework and CLI for automating updates of any kind in code projects.")
150 |
151 | ### Contributing
152 |
153 | Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
154 |
155 | ### Running tests
156 |
157 | Install dev dependencies:
158 |
159 | ```sh
160 | $ npm install -d && npm test
161 | ```
162 |
163 | ### Author
164 |
165 | **Jon Schlinkert**
166 |
167 | * [github/jonschlinkert](https://github.com/jonschlinkert)
168 | * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
169 |
170 | ### License
171 |
172 | Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
173 | Released under the [MIT license](https://github.com/assemble/assemble-nunjucks/blob/master/LICENSE).
174 |
175 | ***
176 |
177 | _This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on July 26, 2016._
--------------------------------------------------------------------------------