@midwayjs/view-nunjucks 3.4.1 → 3.4.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.
@@ -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.1",
3
+ "version": "3.4.6",
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.1",
31
+ "@midwayjs/view": "^3.4.6",
32
32
  "nunjucks": "^3.2.2"
33
33
  },
34
34
  "devDependencies": {
35
- "@midwayjs/core": "^3.4.1",
36
- "@midwayjs/decorator": "^3.4.1",
37
- "@midwayjs/koa": "^3.4.1",
38
- "@midwayjs/mock": "^3.4.1"
35
+ "@midwayjs/core": "^3.4.6",
36
+ "@midwayjs/decorator": "^3.4.4",
37
+ "@midwayjs/koa": "^3.4.6",
38
+ "@midwayjs/mock": "^3.4.6"
39
39
  },
40
- "gitHead": "c7b47267c80f93407537677d8366f68bc6dfc462"
40
+ "gitHead": "36687482782bcf526efc2a4773c09e166820c1a8"
41
41
  }