mm_tpl 2.3.4 → 2.3.6

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.js +30 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -41,7 +41,7 @@ class Tpl {
41
41
  rules: [nativeRule, artRule, htmlRule, jsRule, pyRule, pyRule2],
42
42
  cache_root: './cache'.fullname(),
43
43
  cache_extname: '.cache.html',
44
- change_str: ["\\$", "\\\\", "\\<", "\\>"],
44
+ change_str: ["\\$", "\\/", "\\#", "\\<", "\\>", '\\"""'],
45
45
  };
46
46
 
47
47
  /**
@@ -104,7 +104,7 @@ Tpl.prototype.set_config = function(config) {
104
104
 
105
105
 
106
106
  /**
107
- * 初始化
107
+ * 执行函数钩子
108
108
  * @param {String} name 名称
109
109
  * @param {Object} req 请求参数
110
110
  * @param {Object} args 附加参数
@@ -113,12 +113,27 @@ Tpl.prototype.runFunc = function(name, req, ...args) {
113
113
  return $.hook.runFunc(name, this.viewBag, req, ...args);
114
114
  }
115
115
 
116
+
116
117
  /**
117
- * 初始化
118
+ * 初始化之前
118
119
  * @param {Object} config 配置参数
119
120
  */
120
- Tpl.prototype.init = function(config) {
121
+ Tpl.prototype.init_before = function(config) {
122
+ }
123
+
124
+ /**
125
+ * 初始化主体
126
+ * @param {Object} config 配置参数
127
+ */
128
+ Tpl.prototype.init_main = function(config) {
121
129
  this.set_config(config);
130
+ }
131
+
132
+ /**
133
+ * 初始化之后
134
+ * @param {Object} config 配置参数
135
+ */
136
+ Tpl.prototype.init_after = function(config) {
122
137
  var lt = this.config.change_str;
123
138
  for (var i = 0; i < lt.length; i++) {
124
139
  var str = lt[i];
@@ -131,6 +146,16 @@ Tpl.prototype.init = function(config) {
131
146
  }
132
147
  }
133
148
 
149
+ /**
150
+ * 初始化
151
+ * @param {Object} config 配置参数
152
+ */
153
+ Tpl.prototype.init = function(config) {
154
+ this.init_before(config);
155
+ this.init_main(config);
156
+ this.init_after(config);
157
+ }
158
+
134
159
  /**
135
160
  * 转译字符
136
161
  * @param {String} body 字符串
@@ -272,7 +297,7 @@ Tpl.prototype.render_sub = function(body, model, options) {
272
297
  Tpl.prototype.render = function(body, model, options) {
273
298
  body = this.change(body);
274
299
  body = this.render_sub(body);
275
- return this.change(body, true);
300
+ return this.change(body, true);
276
301
  };
277
302
 
278
303
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_tpl",
3
- "version": "2.3.4",
3
+ "version": "2.3.6",
4
4
  "description": "这是超级美眉模板帮助类模块,用于MVC模式下的视图渲染",
5
5
  "main": "index.js",
6
6
  "scripts": {