mm_tpl 2.2.2 → 2.2.4

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.
@@ -9,6 +9,7 @@
9
9
  <div><div class="bar_user"><div>您好吗?</div><div>你好!</div>
10
10
  <div>用户ID:1</div>
11
11
  <div>当前项目ID:2</div>
12
+ <div>hello world!</div>
12
13
  </div>
13
14
 
14
15
  <div class="bar">导航栏</div>
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- require('mm_expand');
1
+ require('mm_expand');
2
2
  const template = require('art-template');
3
3
  const Hook = require('./hook.js');
4
4
  const {
@@ -35,8 +35,8 @@ class Tpl {
35
35
  */
36
36
  this.config = {
37
37
  root: $.runPath + '',
38
- defualt_dir: "./template/",
39
- defualt_theme: 'defualt',
38
+ default_dir: "./template/",
39
+ default_theme: 'default',
40
40
  extname: ".html",
41
41
  rules: [nativeRule, artRule, htmlRule, jsRule, pyRule, pyRule2],
42
42
  cache_root: './cache'.fullname(),
@@ -64,7 +64,7 @@ class Tpl {
64
64
  /**
65
65
  * 当前主题
66
66
  */
67
- this.current_theme = this.config.defualt_theme;
67
+ this.current_theme = this.config.default_theme;
68
68
 
69
69
  /**
70
70
  * 错误提示
@@ -146,10 +146,10 @@ Tpl.prototype.render_before = function(body, model, options) {
146
146
  Tpl.prototype.loadFunc = function(m) {
147
147
  var _this = this;
148
148
  m.view = function(file, model, options) {
149
- return _this.view(file, model, options);
149
+ return _this.view(file, Object.assign({}, m, model), options);
150
150
  }
151
151
  m.render = function(body, model, options) {
152
- return _this.render(body, model, options);
152
+ return _this.render(body, Object.assign({}, m, model), options);
153
153
  }
154
154
  m.hook_action = function(name, ...args) {
155
155
  return $.hook.runAction(name, m, ...args);
@@ -248,11 +248,11 @@ Tpl.prototype.view = function(file, model, options) {
248
248
  }
249
249
  var f = file.fullname(this.dir + this.current_theme);
250
250
  if (!f.hasFile()) {
251
- f = file.fullname(this.dir + this.config.defualt_theme);
251
+ f = file.fullname(this.dir + this.config.default_theme);
252
252
  if (!f.hasFile()) {
253
- f = file.fullname(this.config.defualt_dir + this.current_theme);
253
+ f = file.fullname(this.config.default_dir + this.current_theme);
254
254
  if (!f.hasFile()) {
255
- f = file.fullname(this.config.defualt_dir + this.config.defualt_theme);
255
+ f = file.fullname(this.config.default_dir + this.config.default_theme);
256
256
  }
257
257
  }
258
258
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_tpl",
3
- "version": "2.2.2",
3
+ "version": "2.2.4",
4
4
  "description": "这是超级美眉模板帮助类模块,用于MVC模式下的视图渲染",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -2,6 +2,7 @@
2
2
  ${@hook_filter('test', hook_action('test', '好的'), '真的')}
3
3
  <div>用户ID:${viewBag.user_id}</div>
4
4
  <div>当前项目ID:${viewBag.project_id}</div>
5
+ <div>${message}</div>
5
6
  </div>
6
7
 
7
8
  <div class="bar">导航栏</div>
package/test.js CHANGED
@@ -84,7 +84,8 @@ async function test() {
84
84
 
85
85
  // 渲染视图(并缓存)
86
86
  var body = tpl.view("./test", {
87
- arr: [123, 234]
87
+ arr: [123, 234],
88
+ message: "hello world!"
88
89
  }, {
89
90
  // 是否读取缓存文件, 如果为false, 但有cache_filename, 表示只保存缓存,但不读取
90
91
  cache: false,