@dryfeld/nunjucks-loader 4.0.4 → 4.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +12 -12
- package/package.json +1 -1
- package/vendor/nunjucks.js +6870 -0
- package/vendor/nunjucks.slim.js +3450 -0
package/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
******************************************************************/
|
|
9
9
|
|
|
10
|
-
const nunjucks = require('nunjucks');
|
|
10
|
+
const nunjucks = require('./vendor/nunjucks.js');
|
|
11
11
|
const path = require('path');
|
|
12
12
|
let hasRun = false;
|
|
13
13
|
let env;
|
|
@@ -27,21 +27,20 @@ module.exports = function (source) {
|
|
|
27
27
|
if (!hasRun) {
|
|
28
28
|
const query = new URLSearchParams(this.query);
|
|
29
29
|
|
|
30
|
-
envOpts = query.
|
|
31
|
-
if (query)
|
|
30
|
+
envOpts = query.opts || {};
|
|
31
|
+
if (query){
|
|
32
32
|
|
|
33
33
|
env = new nunjucks.Environment([], envOpts);
|
|
34
34
|
|
|
35
|
-
if (query.
|
|
36
|
-
pathToConfigure = query.
|
|
35
|
+
if (query.config){
|
|
36
|
+
pathToConfigure = query.config;
|
|
37
37
|
try {
|
|
38
|
-
const configure = require(
|
|
39
|
-
|
|
38
|
+
const configure = require(query.config);
|
|
40
39
|
configure(env);
|
|
41
40
|
}
|
|
42
41
|
catch (e) {
|
|
43
42
|
if (e.code === 'MODULE_NOT_FOUND') {
|
|
44
|
-
if (!query.
|
|
43
|
+
if (!query.quiet) {
|
|
45
44
|
const message = 'Cannot configure nunjucks environment before precompile\n' +
|
|
46
45
|
'\t' + e.message + '\n' +
|
|
47
46
|
'Async filters and custom extensions are unsupported when the nunjucks\n' +
|
|
@@ -60,12 +59,12 @@ module.exports = function (source) {
|
|
|
60
59
|
|
|
61
60
|
// Specify the template search path, so we know from what directory
|
|
62
61
|
// it should be relative to.
|
|
63
|
-
if (query.
|
|
64
|
-
root = query.
|
|
62
|
+
if (query.root) {
|
|
63
|
+
root = query.root;
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
// Enable experimental Jinja compatibility to be enabled
|
|
68
|
-
if(query.
|
|
67
|
+
if(query.jinjaCompat){
|
|
69
68
|
jinjaCompatStr = 'nunjucks.installJinjaCompat();\n';
|
|
70
69
|
}
|
|
71
70
|
}
|
|
@@ -93,8 +92,9 @@ module.exports = function (source) {
|
|
|
93
92
|
// ================================================================
|
|
94
93
|
// Begin to write the compiled template output to return to webpack
|
|
95
94
|
// ================================================================
|
|
95
|
+
|
|
96
96
|
let compiledTemplate = '';
|
|
97
|
-
compiledTemplate += 'var nunjucks = require("nunjucks/
|
|
97
|
+
compiledTemplate += 'var nunjucks = require("@dryfeld/nunjucks-loader/vendor/nunjucks.slim.js");';
|
|
98
98
|
if (jinjaCompatStr) {
|
|
99
99
|
compiledTemplate += jinjaCompatStr + '\n';
|
|
100
100
|
}
|