@midwayjs/view 3.5.0 → 3.5.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.
- package/dist/contextView.js +2 -2
- package/dist/viewManager.d.ts +18 -6
- package/dist/viewManager.js +18 -0
- package/package.json +5 -6
- package/LICENSE +0 -21
package/dist/contextView.js
CHANGED
|
@@ -33,7 +33,7 @@ let ContextView = class ContextView {
|
|
|
33
33
|
let viewEngineName = options.viewEngine;
|
|
34
34
|
if (!viewEngineName) {
|
|
35
35
|
const ext = (0, path_1.extname)(filename);
|
|
36
|
-
viewEngineName = this.viewManager.
|
|
36
|
+
viewEngineName = this.viewManager.findEngine(ext);
|
|
37
37
|
}
|
|
38
38
|
// use the default view engine that is configured if no matching above
|
|
39
39
|
if (!viewEngineName) {
|
|
@@ -69,7 +69,7 @@ let ContextView = class ContextView {
|
|
|
69
69
|
return engine;
|
|
70
70
|
}
|
|
71
71
|
setLocals(locals) {
|
|
72
|
-
return Object.assign({
|
|
72
|
+
return Object.assign({}, this.viewManager.getLocals(), {
|
|
73
73
|
ctx: this.ctx,
|
|
74
74
|
request: this.ctx.request,
|
|
75
75
|
}, this.ctx.locals, locals);
|
package/dist/viewManager.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { IViewEngine } from './interface';
|
|
2
2
|
export declare class ViewManager extends Map {
|
|
3
|
-
app: any;
|
|
4
|
-
viewConfig: any;
|
|
5
|
-
config: any;
|
|
6
|
-
extMap: Map<any, any>;
|
|
7
|
-
fileMap: Map<any, any>;
|
|
8
|
-
|
|
3
|
+
protected app: any;
|
|
4
|
+
protected viewConfig: any;
|
|
5
|
+
protected config: any;
|
|
6
|
+
protected extMap: Map<any, any>;
|
|
7
|
+
protected fileMap: Map<any, any>;
|
|
8
|
+
protected localsMap: {};
|
|
9
|
+
protected init(): void;
|
|
9
10
|
/**
|
|
10
11
|
* This method can register view engine.
|
|
11
12
|
*
|
|
@@ -29,5 +30,16 @@ export declare class ViewManager extends Map {
|
|
|
29
30
|
* @return {String} filename - the full path
|
|
30
31
|
*/
|
|
31
32
|
resolve(name: string): Promise<string>;
|
|
33
|
+
/**
|
|
34
|
+
* add a global data for all views
|
|
35
|
+
* @param key
|
|
36
|
+
* @param localValue
|
|
37
|
+
*/
|
|
38
|
+
addLocals(key: any, localValue: any): void;
|
|
39
|
+
/**
|
|
40
|
+
* get global locals data
|
|
41
|
+
*/
|
|
42
|
+
getLocals(): {};
|
|
43
|
+
findEngine(ext: string): string;
|
|
32
44
|
}
|
|
33
45
|
//# sourceMappingURL=viewManager.d.ts.map
|
package/dist/viewManager.js
CHANGED
|
@@ -19,6 +19,7 @@ let ViewManager = class ViewManager extends Map {
|
|
|
19
19
|
super(...arguments);
|
|
20
20
|
this.extMap = new Map();
|
|
21
21
|
this.fileMap = new Map();
|
|
22
|
+
this.localsMap = {};
|
|
22
23
|
}
|
|
23
24
|
init() {
|
|
24
25
|
this.config = this.viewConfig;
|
|
@@ -79,6 +80,23 @@ let ViewManager = class ViewManager extends Map {
|
|
|
79
80
|
this.fileMap.set(name, filename);
|
|
80
81
|
return filename;
|
|
81
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* add a global data for all views
|
|
85
|
+
* @param key
|
|
86
|
+
* @param localValue
|
|
87
|
+
*/
|
|
88
|
+
addLocals(key, localValue) {
|
|
89
|
+
this.localsMap[key] = localValue;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* get global locals data
|
|
93
|
+
*/
|
|
94
|
+
getLocals() {
|
|
95
|
+
return this.localsMap;
|
|
96
|
+
}
|
|
97
|
+
findEngine(ext) {
|
|
98
|
+
return this.extMap.get(ext);
|
|
99
|
+
}
|
|
82
100
|
};
|
|
83
101
|
__decorate([
|
|
84
102
|
(0, decorator_1.App)(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/view",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.2",
|
|
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.5.
|
|
30
|
+
"@midwayjs/core": "^3.5.1",
|
|
31
31
|
"@midwayjs/decorator": "^3.4.11",
|
|
32
|
-
"@midwayjs/koa": "^3.5.
|
|
33
|
-
"@midwayjs/mock": "^3.5.
|
|
34
|
-
}
|
|
35
|
-
"gitHead": "4200e30d1af97a7817c36899c4ffc41a7d97c06d"
|
|
32
|
+
"@midwayjs/koa": "^3.5.1",
|
|
33
|
+
"@midwayjs/mock": "^3.5.1"
|
|
34
|
+
}
|
|
36
35
|
}
|
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.
|