mm_tpl 2.3.3 → 2.3.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.
- package/index.js +18 -5
- package/package.json +1 -1
- package/template/default/test.html +5 -5
- package/cache/test.cache.html +0 -30
package/index.js
CHANGED
|
@@ -244,7 +244,6 @@ Tpl.prototype.render_after = function(body, model, options) {
|
|
|
244
244
|
return body;
|
|
245
245
|
};
|
|
246
246
|
|
|
247
|
-
|
|
248
247
|
/**
|
|
249
248
|
* 渲染模板
|
|
250
249
|
* @param {String} body 模板
|
|
@@ -252,8 +251,7 @@ Tpl.prototype.render_after = function(body, model, options) {
|
|
|
252
251
|
* @param {Object} options 配置参数
|
|
253
252
|
* @return {String} view 渲染后的视图
|
|
254
253
|
*/
|
|
255
|
-
Tpl.prototype.
|
|
256
|
-
body = this.change(body);
|
|
254
|
+
Tpl.prototype.render_sub = function(body, model, options) {
|
|
257
255
|
var ret = this.render_before(body, model, options);
|
|
258
256
|
if (!ret) {
|
|
259
257
|
ret = this.render_main(body, model, options);
|
|
@@ -261,10 +259,22 @@ Tpl.prototype.render = function(body, model, options) {
|
|
|
261
259
|
ret = this.render_after(ret, model, options);
|
|
262
260
|
}
|
|
263
261
|
}
|
|
264
|
-
ret = this.change(ret, true);
|
|
265
262
|
return ret;
|
|
266
263
|
};
|
|
267
264
|
|
|
265
|
+
/**
|
|
266
|
+
* 渲染模板
|
|
267
|
+
* @param {String} body 模板
|
|
268
|
+
* @param {Object} model 数据模型
|
|
269
|
+
* @param {Object} options 配置参数
|
|
270
|
+
* @return {String} view 渲染后的视图
|
|
271
|
+
*/
|
|
272
|
+
Tpl.prototype.render = function(body, model, options) {
|
|
273
|
+
body = this.change(body);
|
|
274
|
+
body = this.render_sub(body);
|
|
275
|
+
return this.change(body, true);
|
|
276
|
+
};
|
|
277
|
+
|
|
268
278
|
/**
|
|
269
279
|
* 编译模板并返回渲染函数
|
|
270
280
|
* @param {String} body 模板
|
|
@@ -311,7 +321,10 @@ Tpl.prototype.view = function(file, model, options) {
|
|
|
311
321
|
}
|
|
312
322
|
var body = f.loadText();
|
|
313
323
|
if (body) {
|
|
314
|
-
|
|
324
|
+
body = this.change(body);
|
|
325
|
+
body = this.render_sub(body, model, options);
|
|
326
|
+
body = this.change(body, true);
|
|
327
|
+
return body;
|
|
315
328
|
} else {
|
|
316
329
|
return "";
|
|
317
330
|
}
|
package/package.json
CHANGED
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
<body>
|
|
8
8
|
<h5>${viewBag.name}</h5>
|
|
9
9
|
<ul>
|
|
10
|
-
|
|
11
|
-
<li
|
|
12
|
-
|
|
10
|
+
${loop arr value idx}
|
|
11
|
+
<li>${ value }</li>
|
|
12
|
+
${/loop}
|
|
13
13
|
</ul>
|
|
14
14
|
<ul>
|
|
15
|
-
|
|
15
|
+
<!--[ for(var i = 0; i < arr.length; i++) { ]-->
|
|
16
16
|
<li>${ arr[i] }</li>
|
|
17
|
-
|
|
17
|
+
<!--[ } ]-->
|
|
18
18
|
</ul>
|
|
19
19
|
<ul>
|
|
20
20
|
<!--{loop arr value idx}-->
|
package/cache/test.cache.html
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<title>超级美眉Art模板引擎</title>
|
|
6
|
-
</head>
|
|
7
|
-
<body>
|
|
8
|
-
<h5>系统名称</h5>
|
|
9
|
-
<p>您真的是人才!</p>
|
|
10
|
-
<p>您真的是人才!</p>
|
|
11
|
-
<ul>
|
|
12
|
-
<li>\123</li>
|
|
13
|
-
<li>\234</li>
|
|
14
|
-
</ul>
|
|
15
|
-
<ul>
|
|
16
|
-
<li>123</li>
|
|
17
|
-
<li>234</li>
|
|
18
|
-
</ul>
|
|
19
|
-
<ul>
|
|
20
|
-
<li>\123</li>
|
|
21
|
-
<li>\234</li>
|
|
22
|
-
</ul>
|
|
23
|
-
<script type="text/javascript">
|
|
24
|
-
var a_0 =123;
|
|
25
|
-
var a_1 =234;
|
|
26
|
-
</script>系统名称计算
|
|
27
|
-
123123'priceNIHAO'#计算
|
|
28
|
-
</body>
|
|
29
|
-
</html>
|
|
30
|
-
$
|