@midwayjs/view 2.13.0 → 2.13.1

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.
Files changed (2) hide show
  1. package/index.d.ts +47 -0
  2. package/package.json +3 -2
package/index.d.ts ADDED
@@ -0,0 +1,47 @@
1
+ export * from './dist/index';
2
+
3
+ interface RenderOptions {
4
+ name?: string;
5
+ root?: string;
6
+ locals?: Record<string, any>;
7
+ viewEngine?: string;
8
+ }
9
+
10
+ declare module '@midwayjs/core/dist/interface' {
11
+ interface Context {
12
+ /**
13
+ * Render a file by view engine, then set to body
14
+ * @param {String} name - the file path based on root
15
+ * @param {Object} [locals] - data used by template
16
+ * @param {Object} [options] - view options, you can use `options.viewEngine` to specify view engine
17
+ * @return {Promise<String>} result - return a promise with a render result
18
+ */
19
+ render(name: string, locals?: any, options?: RenderOptions): Promise<null>;
20
+
21
+ /**
22
+ * Render a file by view engine and return it
23
+ * @param {String} name - the file path based on root
24
+ * @param {Object} [locals] - data used by template
25
+ * @param {Object} [options] - view options, you can use `options.viewEngine` to specify view engine
26
+ * @return {Promise<String>} result - return a promise with a render result
27
+ */
28
+ renderView(
29
+ name: string,
30
+ locals?: any,
31
+ options?: RenderOptions
32
+ ): Promise<string>;
33
+
34
+ /**
35
+ * Render a template string by view engine
36
+ * @param {String} tpl - template string
37
+ * @param {Object} [locals] - data used by template
38
+ * @param {Object} [options] - view options, you can use `options.viewEngine` to specify view engine
39
+ * @return {Promise<String>} result - return a promise with a render result
40
+ */
41
+ renderString(
42
+ name: string,
43
+ locals?: any,
44
+ options?: RenderOptions
45
+ ): Promise<string>;
46
+ }
47
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/view",
3
- "version": "2.13.0",
3
+ "version": "2.13.1",
4
4
  "description": "Midway Component for egg-view",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
@@ -20,7 +20,8 @@
20
20
  "author": "",
21
21
  "files": [
22
22
  "dist/**/*.js",
23
- "dist/**/*.d.ts"
23
+ "dist/**/*.d.ts",
24
+ "index.d.ts"
24
25
  ],
25
26
  "engines": {
26
27
  "node": ">= 12.13.0"