Skip to content

Commit dfe5992

Browse files
Dan Whitebmuenzenmeyer
authored andcommitted
Load Pattern Lab config and replace hardcoded references to the Patterns dir
1 parent 0cee05a commit dfe5992

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

packages/patternengine-node-nunjucks/lib/engine_nunjucks.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
TODO
33
- Make sure regex match Nunjucks features and syntax
44
- Look into if we need to handle partials in the render method
5-
- Replace 'source/patterns' string with a config variable from PL if possible
65
- Add try catch blocks to prevent Pl from crashing
76
- Test methods of including files
87
- Compare features and syntax with the mustache version so we can document
@@ -11,11 +10,14 @@
1110

1211
"use strict";
1312

14-
var _shuffle = require('lodash/shuffle');
15-
var _take = require('lodash/take');
16-
var nunjucks = require('nunjucks');
17-
var env = nunjucks.configure('source/_patterns/');
18-
var partialRegistry = [];
13+
var path = require('path'),
14+
plPath = process.cwd(),
15+
plConfig = require(path.join(plPath, 'patternlab-config.json')),
16+
_shuffle = require('lodash/shuffle'),
17+
_take = require('lodash/take'),
18+
nunjucks = require('nunjucks'),
19+
env = nunjucks.configure(plConfig.paths.source.patterns),
20+
partialRegistry = [];
1921

2022

2123
////////////////////////////

0 commit comments

Comments
 (0)