@midwayjs/view-ejs 3.0.1 → 3.0.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.default.js","sourceRoot":"","sources":["../../src/config/config.default.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAE7B,kBAAe,OAAO,CAAC,EAAE;IACvB,OAAO;QACL;;;;;;;;WAQG;QACH,GAAG,EAAE;YACH,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC;YACvC,KAAK,EAAE,IAAI;YACX,KAAK,EAAE,KAAK;YACZ,YAAY,EAAE,IAAI;YAClB,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,KAAK;SACd;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import * as path from 'path';\n\nexport default appInfo => {\n return {\n /**\n * @member Config#ejs\n * @property {String} [root=${appDir}/view] - the root directory of ejs files\n * @property {Boolean} [cache=true] - compiled functions are cached, only work using `ctx.render`\n * @property {Boolean} [debug=false] - output generated function body\n * @property {Boolean} [compileDebug=true] - when false no debug instrumentation is compiled\n * @property {String} [delimiter] - character to use with angle brackets for open/close\n * @property {Boolean} [strict=false] - when set to true, generated function is in strict mode\n */\n ejs: {\n root: path.join(appInfo.appDir, 'view'),\n cache: true,\n debug: false,\n compileDebug: true,\n delimiter: null,\n strict: false,\n },\n };\n};\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.local.js","sourceRoot":"","sources":["../../src/config/config.local.ts"],"names":[],"mappings":";;;AAAa,QAAA,GAAG,GAAG;IACjB,KAAK,EAAE,KAAK;CACb,CAAC","sourcesContent":["export const ejs = {\n cache: false,\n};\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAA4D;AAC5D,uCAAuC;AACvC,yDAAyD;AACzD,qDAAqD;AACrD,iCAAiC;AAYjC,IAAa,oBAAoB,GAAjC,MAAa,oBAAoB;IAI/B,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,cAAO,CAAC,CAAC;IACvC,CAAC;CACF,CAAA;AALC;IADC,IAAA,kBAAM,GAAE;8BACI,IAAI,CAAC,WAAW;yDAAC;AAFnB,oBAAoB;IAVhC,IAAA,yBAAa,EAAC;QACb,SAAS,EAAE,UAAU;QACrB,aAAa,EAAE;YACb;gBACE,OAAO,EAAE,aAAa;gBACtB,KAAK,EAAE,WAAW;aACnB;SACF;QACD,OAAO,EAAE,CAAC,IAAI,CAAC;KAChB,CAAC;GACW,oBAAoB,CAOhC;AAPY,oDAAoB","sourcesContent":["import { Configuration, Inject } from '@midwayjs/decorator';\nimport * as View from '@midwayjs/view';\nimport * as DefaultConfig from './config/config.default';\nimport * as LocalConfig from './config/config.local';\nimport { EjsView } from './view';\n\n@Configuration({\n namespace: 'view-ejs',\n importConfigs: [\n {\n default: DefaultConfig,\n local: LocalConfig,\n },\n ],\n imports: [View],\n})\nexport class ViewEJSConfiguration {\n @Inject()\n viewManager: View.ViewManager;\n\n async onReady() {\n this.viewManager.use('ejs', EjsView);\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,iDAAwE;AAA/D,8GAAA,oBAAoB,OAAiB;AAC9C,yCAAuB","sourcesContent":["export { ViewEJSConfiguration as Configuration } from './configuration';\nexport * from './view';\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.js","sourceRoot":"","sources":["../src/view.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2BAA2B;AAC3B,yCAAyE;AACzE,mDAA8D;AAG9D,IAAa,OAAO,GAApB,MAAa,OAAO;IAOV,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,M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GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;SACzD;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SAC5B;IACH,CAAC;CACF,CAAA;AAhDC;IADC,IAAA,kBAAM,EAAC,KAAK,CAAC;;0CACJ;AAGV;IADC,IAAA,kBAAM,GAAE;8BACI,kBAAW;4CAAC;AALd,OAAO;IADnB,IAAA,mBAAO,GAAE;GACG,OAAO,CAkDnB;AAlDY,0BAAO","sourcesContent":["import * as ejs from 'ejs';\nimport { IViewEngine, RenderOptions, ViewManager } from '@midwayjs/view';\nimport { Config, Inject, Provide } from '@midwayjs/decorator';\n\n@Provide()\nexport class EjsView implements IViewEngine {\n @Config('ejs')\n ejsConfig;\n\n @Inject()\n viewManager: ViewManager;\n\n private async renderFile(filename, locals, config): Promise<string> {\n return new Promise((resolve, reject) => {\n ejs.renderFile(filename, locals, config, (err, result) => {\n if (err) {\n reject(err);\n } else {\n resolve(result);\n }\n });\n });\n }\n\n async render(\n name: string,\n locals?: Record<string, any>,\n options?: RenderOptions\n ): Promise<string> {\n const config = Object.assign({}, this.ejsConfig, options, { name });\n const html = await this.renderFile(name, locals, config);\n if (!config.layout) {\n return html;\n }\n\n locals.body = html;\n const layout = await this.viewManager.resolve(config.layout);\n return this.renderFile(layout, locals, config);\n }\n\n async renderString(\n tpl: string,\n locals?: Record<string, any>,\n options?: RenderOptions\n ): Promise<string> {\n // should disable cache when no filename\n const config = Object.assign({}, this.ejsConfig, options, {\n cache: null,\n });\n try {\n return Promise.resolve(ejs.render(tpl, locals, config));\n } catch (err) {\n return Promise.reject(err);\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/view-ejs",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "Midway Component for ejs render",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
@@ -21,21 +21,22 @@
21
21
  "files": [
22
22
  "dist/**/*.js",
23
23
  "dist/**/*.d.ts",
24
- "index.d.ts"
24
+ "index.d.ts",
25
+ "dist/**/*.js.map"
25
26
  ],
26
27
  "engines": {
27
28
  "node": ">=12"
28
29
  },
29
30
  "license": "MIT",
30
31
  "dependencies": {
31
- "@midwayjs/view": "^3.0.1",
32
+ "@midwayjs/view": "^3.0.2",
32
33
  "ejs": "3.1.6"
33
34
  },
34
35
  "devDependencies": {
35
- "@midwayjs/core": "^3.0.1",
36
- "@midwayjs/decorator": "^3.0.0",
37
- "@midwayjs/koa": "^3.0.1",
38
- "@midwayjs/mock": "^3.0.1"
36
+ "@midwayjs/core": "^3.0.2",
37
+ "@midwayjs/decorator": "^3.0.2",
38
+ "@midwayjs/koa": "^3.0.2",
39
+ "@midwayjs/mock": "^3.0.2"
39
40
  },
40
- "gitHead": "f345b4ed0392e5c3b9e815438ef0a377ad6da076"
41
+ "gitHead": "ca77247d229978a736e79bb208579c014ed226fc"
41
42
  }