@midwayjs/view-nunjucks 3.0.13 → 3.1.2
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/dist/config/config.default.d.ts +11 -0
- package/dist/engine.js +13 -6
- package/dist/index.js +5 -1
- package/package.json +6 -6
|
@@ -20,6 +20,17 @@ declare const _default: {
|
|
|
20
20
|
* use a cache and recompile templates each time. false in local env.
|
|
21
21
|
*/
|
|
22
22
|
cache: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* defines the syntax for nunjucks tags.
|
|
25
|
+
*/
|
|
26
|
+
tags?: {
|
|
27
|
+
blockStart?: string;
|
|
28
|
+
blockEnd?: string;
|
|
29
|
+
variableStart?: string;
|
|
30
|
+
variableEnd?: string;
|
|
31
|
+
commentStart?: string;
|
|
32
|
+
commentEnd?: string;
|
|
33
|
+
};
|
|
23
34
|
};
|
|
24
35
|
};
|
|
25
36
|
export default _default;
|
package/dist/engine.js
CHANGED
|
@@ -14,9 +14,7 @@ const decorator_1 = require("@midwayjs/decorator");
|
|
|
14
14
|
const nunjucks_1 = require("nunjucks");
|
|
15
15
|
class MidwayNunjucksEnvironment extends nunjucks_1.Environment {
|
|
16
16
|
constructor(fileLoader, config) {
|
|
17
|
-
super(fileLoader,
|
|
18
|
-
noCache: config.noCache,
|
|
19
|
-
});
|
|
17
|
+
super(fileLoader, config);
|
|
20
18
|
// http://disse.cting.org/2016/08/02/2016-08-02-sandbox-break-out-nunjucks-template-engine
|
|
21
19
|
const originMemberLookup = nunjucks_1.runtime.memberLookup;
|
|
22
20
|
nunjucks_1.runtime.memberLookup = function (...args) {
|
|
@@ -31,12 +29,21 @@ let NunjucksEnvironment = class NunjucksEnvironment {
|
|
|
31
29
|
async init() {
|
|
32
30
|
const coreLogger = this.app.getCoreLogger();
|
|
33
31
|
const viewPaths = this.globalConfig.view.root;
|
|
34
|
-
coreLogger.info('[
|
|
32
|
+
coreLogger.info('[midway:view-nunjucks] loading templates from %j', viewPaths);
|
|
35
33
|
const config = this.globalConfig['nunjucks'];
|
|
36
34
|
config.noCache = !config.cache;
|
|
37
35
|
delete config.cache;
|
|
38
|
-
const
|
|
39
|
-
|
|
36
|
+
const nunjucksConfig = {
|
|
37
|
+
noCache: config.noCache,
|
|
38
|
+
throwOnUndefined: config.throwOnUndefined,
|
|
39
|
+
trimBlocks: config.trimBlocks,
|
|
40
|
+
lstripBlocks: config.lstripBlocks,
|
|
41
|
+
tags: config.tags,
|
|
42
|
+
};
|
|
43
|
+
const fileLoader = new nunjucks_1.FileSystemLoader(this.globalConfig.view.root, {
|
|
44
|
+
noCache: nunjucksConfig.noCache,
|
|
45
|
+
});
|
|
46
|
+
this.nunjucksEnvironment = new MidwayNunjucksEnvironment(fileLoader, nunjucksConfig);
|
|
40
47
|
}
|
|
41
48
|
render(name, locals, cb) {
|
|
42
49
|
return this.nunjucksEnvironment.render(name, locals, cb);
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/view-nunjucks",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "Midway Component for nunjucks render",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
},
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@midwayjs/view": "^3.
|
|
31
|
+
"@midwayjs/view": "^3.1.2",
|
|
32
32
|
"nunjucks": "^3.2.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@midwayjs/core": "^3.
|
|
35
|
+
"@midwayjs/core": "^3.1.2",
|
|
36
36
|
"@midwayjs/decorator": "^3.0.10",
|
|
37
|
-
"@midwayjs/koa": "^3.
|
|
38
|
-
"@midwayjs/mock": "^3.
|
|
37
|
+
"@midwayjs/koa": "^3.1.2",
|
|
38
|
+
"@midwayjs/mock": "^3.1.2"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "4ff3aa892b76d016f0ea123c7f9520d054d5c96b"
|
|
41
41
|
}
|