@midwayjs/view 3.5.3 → 3.6.0
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/README.md +5 -5
- package/dist/configuration.js +3 -4
- package/dist/contextView.js +7 -7
- package/dist/viewManager.js +6 -6
- package/package.json +5 -6
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ $ npm i @midwayjs/view-ejs --save
|
|
|
16
16
|
First, import component in `src/configuration.ts`.
|
|
17
17
|
|
|
18
18
|
```typescript
|
|
19
|
-
import { Configuration } from '@midwayjs/
|
|
19
|
+
import { Configuration } from '@midwayjs/core';
|
|
20
20
|
import * as view from '@midwayjs/view-ejs';
|
|
21
21
|
import { join } from 'path'
|
|
22
22
|
|
|
@@ -51,7 +51,7 @@ export const ejs = {};
|
|
|
51
51
|
In controller, you can call `ctx.render`.
|
|
52
52
|
|
|
53
53
|
```typescript
|
|
54
|
-
import { Inject, Provide } from '@midwayjs/
|
|
54
|
+
import { Inject, Provide } from '@midwayjs/core';
|
|
55
55
|
import { Context } from '@midwayjs/koa';
|
|
56
56
|
|
|
57
57
|
@Controller('/')
|
|
@@ -98,7 +98,7 @@ Create a view engine class first, and implement render and renderString, if the
|
|
|
98
98
|
|
|
99
99
|
```typescript
|
|
100
100
|
// lib/view.ts
|
|
101
|
-
import { Provide } from '@midwayjs/
|
|
101
|
+
import { Provide } from '@midwayjs/core';
|
|
102
102
|
|
|
103
103
|
@Provide()
|
|
104
104
|
export class MyView {
|
|
@@ -138,7 +138,7 @@ After define a view engine, you can register it.
|
|
|
138
138
|
|
|
139
139
|
```typescript
|
|
140
140
|
// src/configuration.ts
|
|
141
|
-
import { Configuration, Inject, Provide } from '@midwayjs/
|
|
141
|
+
import { Configuration, Inject, Provide } from '@midwayjs/core';
|
|
142
142
|
import * as koa from '@midwayjs/koa';
|
|
143
143
|
import * as view from '@midwayjs/view';
|
|
144
144
|
import { MyView } from './lib/my';
|
|
@@ -192,7 +192,7 @@ export const view = {
|
|
|
192
192
|
};
|
|
193
193
|
|
|
194
194
|
// controller
|
|
195
|
-
import { Inject, Provide } from '@midwayjs/
|
|
195
|
+
import { Inject, Provide } from '@midwayjs/core';
|
|
196
196
|
import { Context } from '@midwayjs/koa';
|
|
197
197
|
|
|
198
198
|
@Controller('/')
|
package/dist/configuration.js
CHANGED
|
@@ -10,11 +10,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ViewConfiguration = void 0;
|
|
13
|
-
const
|
|
13
|
+
const core_1 = require("@midwayjs/core");
|
|
14
14
|
const DefaultConfig = require("./config/config.default");
|
|
15
15
|
const LocalConfig = require("./config/config.local");
|
|
16
16
|
const viewManager_1 = require("./viewManager");
|
|
17
|
-
const core_1 = require("@midwayjs/core");
|
|
18
17
|
const contextView_1 = require("./contextView");
|
|
19
18
|
let ViewConfiguration = class ViewConfiguration {
|
|
20
19
|
async onReady(container) {
|
|
@@ -60,11 +59,11 @@ let ViewConfiguration = class ViewConfiguration {
|
|
|
60
59
|
}
|
|
61
60
|
};
|
|
62
61
|
__decorate([
|
|
63
|
-
(0,
|
|
62
|
+
(0, core_1.Inject)(),
|
|
64
63
|
__metadata("design:type", core_1.MidwayApplicationManager)
|
|
65
64
|
], ViewConfiguration.prototype, "applicationManager", void 0);
|
|
66
65
|
ViewConfiguration = __decorate([
|
|
67
|
-
(0,
|
|
66
|
+
(0, core_1.Configuration)({
|
|
68
67
|
namespace: 'view',
|
|
69
68
|
importConfigs: [
|
|
70
69
|
{
|
package/dist/contextView.js
CHANGED
|
@@ -11,7 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ContextView = void 0;
|
|
13
13
|
const viewManager_1 = require("./viewManager");
|
|
14
|
-
const
|
|
14
|
+
const core_1 = require("@midwayjs/core");
|
|
15
15
|
const assert = require("assert");
|
|
16
16
|
const path_1 = require("path");
|
|
17
17
|
/**
|
|
@@ -61,10 +61,10 @@ let ContextView = class ContextView {
|
|
|
61
61
|
const engine = await this.ctx.requestContext.getAsync(ViewEngine);
|
|
62
62
|
// wrap render and renderString to support both async function and generator function
|
|
63
63
|
if (engine.render) {
|
|
64
|
-
engine.render =
|
|
64
|
+
engine.render = core_1.Utils.toAsyncFunction(engine.render);
|
|
65
65
|
}
|
|
66
66
|
if (engine.renderString) {
|
|
67
|
-
engine.renderString =
|
|
67
|
+
engine.renderString = core_1.Utils.toAsyncFunction(engine.renderString);
|
|
68
68
|
}
|
|
69
69
|
return engine;
|
|
70
70
|
}
|
|
@@ -76,19 +76,19 @@ let ContextView = class ContextView {
|
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
__decorate([
|
|
79
|
-
(0,
|
|
79
|
+
(0, core_1.Inject)(),
|
|
80
80
|
__metadata("design:type", viewManager_1.ViewManager)
|
|
81
81
|
], ContextView.prototype, "viewManager", void 0);
|
|
82
82
|
__decorate([
|
|
83
|
-
(0,
|
|
83
|
+
(0, core_1.Config)('view'),
|
|
84
84
|
__metadata("design:type", Object)
|
|
85
85
|
], ContextView.prototype, "viewConfig", void 0);
|
|
86
86
|
__decorate([
|
|
87
|
-
(0,
|
|
87
|
+
(0, core_1.Inject)(),
|
|
88
88
|
__metadata("design:type", Object)
|
|
89
89
|
], ContextView.prototype, "ctx", void 0);
|
|
90
90
|
ContextView = __decorate([
|
|
91
|
-
(0,
|
|
91
|
+
(0, core_1.Provide)()
|
|
92
92
|
], ContextView);
|
|
93
93
|
exports.ContextView = ContextView;
|
|
94
94
|
//# sourceMappingURL=contextView.js.map
|
package/dist/viewManager.js
CHANGED
|
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ViewManager = void 0;
|
|
13
|
-
const
|
|
13
|
+
const core_1 = require("@midwayjs/core");
|
|
14
14
|
const assert = require("assert");
|
|
15
15
|
const path = require("path");
|
|
16
16
|
const fs_1 = require("fs");
|
|
@@ -99,22 +99,22 @@ let ViewManager = class ViewManager extends Map {
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
__decorate([
|
|
102
|
-
(0,
|
|
102
|
+
(0, core_1.App)(),
|
|
103
103
|
__metadata("design:type", Object)
|
|
104
104
|
], ViewManager.prototype, "app", void 0);
|
|
105
105
|
__decorate([
|
|
106
|
-
(0,
|
|
106
|
+
(0, core_1.Config)('view'),
|
|
107
107
|
__metadata("design:type", Object)
|
|
108
108
|
], ViewManager.prototype, "viewConfig", void 0);
|
|
109
109
|
__decorate([
|
|
110
|
-
(0,
|
|
110
|
+
(0, core_1.Init)(),
|
|
111
111
|
__metadata("design:type", Function),
|
|
112
112
|
__metadata("design:paramtypes", []),
|
|
113
113
|
__metadata("design:returntype", void 0)
|
|
114
114
|
], ViewManager.prototype, "init", null);
|
|
115
115
|
ViewManager = __decorate([
|
|
116
|
-
(0,
|
|
117
|
-
(0,
|
|
116
|
+
(0, core_1.Provide)(),
|
|
117
|
+
(0, core_1.Scope)(core_1.ScopeEnum.Singleton)
|
|
118
118
|
], ViewManager);
|
|
119
119
|
exports.ViewManager = ViewManager;
|
|
120
120
|
async function resolvePath(names, root) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/view",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Midway Component for render view",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -27,10 +27,9 @@
|
|
|
27
27
|
},
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@midwayjs/core": "^3.
|
|
31
|
-
"@midwayjs/
|
|
32
|
-
"@midwayjs/
|
|
33
|
-
"@midwayjs/mock": "^3.5.3"
|
|
30
|
+
"@midwayjs/core": "^3.6.0",
|
|
31
|
+
"@midwayjs/koa": "^3.6.0",
|
|
32
|
+
"@midwayjs/mock": "^3.6.0"
|
|
34
33
|
},
|
|
35
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "22643b0e8519766bb7c68b975930199fc136336e"
|
|
36
35
|
}
|