From e9f2eed5847e1d2e4674707540ce8aade41cf09c Mon Sep 17 00:00:00 2001 From: Geoffrey Pursell Date: Mon, 3 Apr 2017 22:40:00 -0500 Subject: [PATCH] Add support for load-time config injection --- lib/engine_mustache.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/engine_mustache.js b/lib/engine_mustache.js index c13ee21..ccbf29c 100644 --- a/lib/engine_mustache.js +++ b/lib/engine_mustache.js @@ -22,6 +22,11 @@ var Mustache = require('mustache'); var utilMustache = require('./util_mustache'); +// This holds the config from from core. The core has to call +// usePatternLabConfig() at load time for this to be populated, which +// it does, so we're cool, right? +let patternLabConfig = {}; + var engine_mustache = { engine: Mustache, engineName: 'mustache', @@ -111,6 +116,16 @@ var engine_mustache = { foundPatternPartial = foundPatternPartial.split(':')[0]; return foundPatternPartial; + }, + + /** + * Accept a Pattern Lab config object from the core and put it in + * this module's closure scope so we can configure engine behavior. + * + * @param {object} config - the global config object from core + */ + usePatternLabConfig: function (config) { + patternLabConfig = config; } };