MCPcopy
hub / github.com/MagicMirrorOrg/MagicMirror / nunjucksEnvironment

Method nunjucksEnvironment

js/module.js:162–177  ·  view source on GitHub ↗

* Returns the nunjucks environment for the current module. * The environment is checked in the _nunjucksEnvironment instance variable. * @returns {object} The Nunjucks Environment

()

Source from the content-addressed store, hash-verified

160 * @returns {object} The Nunjucks Environment
161 */
162 nunjucksEnvironment () {
163 if (this._nunjucksEnvironment !== null) {
164 return this._nunjucksEnvironment;
165 }
166
167 this._nunjucksEnvironment = new nunjucks.Environment(new nunjucks.WebLoader(this.file(""), { async: true }), {
168 trimBlocks: true,
169 lstripBlocks: true
170 });
171
172 this._nunjucksEnvironment.addFilter("translate", (str, variables) => {
173 return nunjucks.runtime.markSafe(this.translate(str, variables));
174 });
175
176 return this._nunjucksEnvironment;
177 }
178
179 /**
180 * Called when a socket notification arrives.

Callers 4

getDomMethod · 0.95
renderMessageFunction · 0.80
addFiltersFunction · 0.80
addFiltersFunction · 0.80

Calls 2

fileMethod · 0.95
translateMethod · 0.95

Tested by

no test coverage detected