You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[ ][Pattern Parameters](http://patternlab.io/docs/pattern-parameters.html) (Accomplished instead using [native Handlebars partial arguments](http://handlebarsjs.com/partials.html))
13
13
*[ ][Style Modifiers](http://patternlab.io/docs/pattern-stylemodifier.html) (Accomplished instead using [native Handlebars partial arguments](http://handlebarsjs.com/partials.html))
14
+
15
+
## Helpers
16
+
17
+
To add custom [helpers](http://handlebarsjs.com/#helpers) or otherwise interact with Handlebars directly, create a file named `patternlab-handlebars-config.js` in the root of your Pattern Lab project, or override the default location by specifying one or several glob patterns in the Pattern Lab config:
18
+
19
+
```json
20
+
{
21
+
...
22
+
"engines": {
23
+
"handlebars": {
24
+
"extend": [
25
+
"handlebars-helpers.js",
26
+
"helpers/**/*.js"
27
+
]
28
+
}
29
+
}
30
+
}
31
+
```
32
+
33
+
Each file should export a function which takes Handlebars as an argument.
Copy file name to clipboardExpand all lines: packages/engine-nunjucks/README.md
+20-2Lines changed: 20 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,16 +17,34 @@ Level of Support is more or less full. Partial calls and lineage hunting are sup
17
17
18
18
## Extending the Nunjucks instance
19
19
20
-
To add custom filters or make customizations to the nunjucks instance, create a file named `patternlab-nunjucks-config.js` in the root of your Pattern Lab project. `patternlab-nunjucks-config.js` should export a function with the Nunjucks environment as parameter.
20
+
To add custom filters or make customizations to the nunjucks instance, add the following to `patternlab-config.json`:
21
21
22
+
```json
23
+
{
24
+
...
25
+
"engines": {
26
+
"nunjucks": {
27
+
"extend": [
28
+
"nunjucks-extensions/*.js"
29
+
]
30
+
}
31
+
}
32
+
}
22
33
```
34
+
35
+
...or use the default file name: `patternlab-nunjucks-config.js` (in the root of your Pattern Lab project).
36
+
37
+
Each file providing extensions should export a function with the Nunjucks environment as parameter.
38
+
39
+
```js
23
40
module.exports=function (env) {
24
41
[YOURCUSTOMCODEHERE]
25
42
};
26
43
```
27
44
28
45
Example: `patternlab-nunjucks-config.js` file that uses lodash and adds three custom filters.
0 commit comments