@midwayjs/view-nunjucks 3.4.3 → 3.4.7

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.
@@ -1,37 +1,6 @@
1
+ import { INunjucksConfig } from '../interface';
1
2
  declare const _default: {
2
- nunjucks: {
3
- /**
4
- * controls if output with dangerous characters are escaped automatically.
5
- */
6
- autoescape: boolean;
7
- /**
8
- * throw errors when outputting a null/undefined value
9
- */
10
- throwOnUndefined: boolean;
11
- /**
12
- * automatically remove trailing newlines from a block/tag
13
- */
14
- trimBlocks: boolean;
15
- /**
16
- * automatically remove leading whitespace from a block/tag
17
- */
18
- lstripBlocks: boolean;
19
- /**
20
- * use a cache and recompile templates each time. false in local env.
21
- */
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
- };
34
- };
3
+ nunjucks: INunjucksConfig;
35
4
  };
36
5
  export default _default;
37
6
  //# sourceMappingURL=config.default.d.ts.map
package/dist/engine.d.ts CHANGED
@@ -1,10 +1,12 @@
1
+ import { Environment, TemplateCallback } from 'nunjucks';
2
+ import { RenderOptions } from '@midwayjs/view';
1
3
  export declare class NunjucksEnvironment {
2
- protected nunjucksEnvironment: any;
4
+ protected nunjucksEnvironment: Environment;
3
5
  protected app: any;
4
6
  protected globalConfig: any;
5
7
  protected init(): Promise<void>;
6
- render(name: any, locals: any, cb: any): any;
7
- renderString(tpl: any, locals: any, opts: any, cb: any): any;
8
+ render(name: string, context?: Record<string, any>, callback?: TemplateCallback<string>): any;
9
+ renderString(tpl: string, context?: Record<string, any>, options?: RenderOptions, callback?: TemplateCallback<string>): any;
8
10
  addFilter(name: string, callback: (...args: any[]) => string): any;
9
11
  getFilter(name: string): any;
10
12
  hasExtension(name: string): boolean;
package/dist/engine.js CHANGED
@@ -39,17 +39,18 @@ let NunjucksEnvironment = class NunjucksEnvironment {
39
39
  trimBlocks: config.trimBlocks,
40
40
  lstripBlocks: config.lstripBlocks,
41
41
  tags: config.tags,
42
+ autoescape: config.autoescape,
42
43
  };
43
44
  const fileLoader = new nunjucks_1.FileSystemLoader(this.globalConfig.view.root, {
44
45
  noCache: nunjucksConfig.noCache,
45
46
  });
46
47
  this.nunjucksEnvironment = new MidwayNunjucksEnvironment(fileLoader, nunjucksConfig);
47
48
  }
48
- render(name, locals, cb) {
49
- return this.nunjucksEnvironment.render(name, locals, cb);
49
+ render(name, context, callback) {
50
+ return this.nunjucksEnvironment.render(name, context, callback);
50
51
  }
51
- renderString(tpl, locals, opts, cb) {
52
- return this.nunjucksEnvironment.renderString(tpl, locals, opts, cb);
52
+ renderString(tpl, context, options, callback) {
53
+ return this.nunjucksEnvironment.renderString(tpl, context, options, callback);
53
54
  }
54
55
  addFilter(name, callback) {
55
56
  return this.nunjucksEnvironment.addFilter(name, callback);
@@ -0,0 +1,34 @@
1
+ export interface INunjucksConfig {
2
+ /**
3
+ * controls if output with dangerous characters are escaped automatically.
4
+ */
5
+ autoescape: boolean;
6
+ /**
7
+ * throw errors when outputting a null/undefined value
8
+ */
9
+ throwOnUndefined: boolean;
10
+ /**
11
+ * automatically remove trailing newlines from a block/tag
12
+ */
13
+ trimBlocks: boolean;
14
+ /**
15
+ * automatically remove leading whitespace from a block/tag
16
+ */
17
+ lstripBlocks: boolean;
18
+ /**
19
+ * use a cache and recompile templates each time. false in local env.
20
+ */
21
+ cache: boolean;
22
+ /**
23
+ * defines the syntax for nunjucks tags.
24
+ */
25
+ tags?: {
26
+ blockStart?: string;
27
+ blockEnd?: string;
28
+ variableStart?: string;
29
+ variableEnd?: string;
30
+ commentStart?: string;
31
+ commentEnd?: string;
32
+ };
33
+ }
34
+ //# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ;
4
+ //# sourceMappingURL=interface.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/view-nunjucks",
3
- "version": "3.4.3",
3
+ "version": "3.4.7",
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.4.3",
31
+ "@midwayjs/view": "^3.4.7",
32
32
  "nunjucks": "^3.2.2"
33
33
  },
34
34
  "devDependencies": {
35
- "@midwayjs/core": "^3.4.3",
36
- "@midwayjs/decorator": "^3.4.1",
37
- "@midwayjs/koa": "^3.4.3",
38
- "@midwayjs/mock": "^3.4.3"
35
+ "@midwayjs/core": "^3.4.7",
36
+ "@midwayjs/decorator": "^3.4.4",
37
+ "@midwayjs/koa": "^3.4.7",
38
+ "@midwayjs/mock": "^3.4.7"
39
39
  },
40
- "gitHead": "0d79293f56d01a3ef3589e6a6ef53c582ac0c46f"
40
+ "gitHead": "3c60619a65c6776d99fbf0b30ac454d3cb6926b9"
41
41
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2013 - Now midwayjs
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.