mm_tpl 2.3.5 → 2.3.7
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 +11 -8
- 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
|
/**
|
|
@@ -118,8 +118,7 @@ Tpl.prototype.runFunc = function(name, req, ...args) {
|
|
|
118
118
|
* 初始化之前
|
|
119
119
|
* @param {Object} config 配置参数
|
|
120
120
|
*/
|
|
121
|
-
Tpl.prototype.init_before = function(config) {
|
|
122
|
-
}
|
|
121
|
+
Tpl.prototype.init_before = function(config) {}
|
|
123
122
|
|
|
124
123
|
/**
|
|
125
124
|
* 初始化主体
|
|
@@ -137,11 +136,15 @@ Tpl.prototype.init_after = function(config) {
|
|
|
137
136
|
var lt = this.config.change_str;
|
|
138
137
|
for (var i = 0; i < lt.length; i++) {
|
|
139
138
|
var str = lt[i];
|
|
140
|
-
var
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
this.
|
|
139
|
+
var rx_in = str.replace("\\", "\\\\").replace("$", "\\$").replace("[", "\\[").replace("]", "\\]").replace(
|
|
140
|
+
"{", "\\{").replace("}", "\\}").replace("/", "\\/").replace("*", "\\*");
|
|
141
|
+
this.regex_in.push(new RegExp(rx_in, "gi"));
|
|
142
|
+
var str_in = str.split("").join("·") + "·";
|
|
143
|
+
this.str_in.push(str_in);
|
|
144
|
+
var rx_out = str_in.replace("\\", "\\\\").replace("$", "\\$").replace("[", "\\[").replace("]", "\\]")
|
|
145
|
+
.replace(
|
|
146
|
+
"{", "\\{").replace("}", "\\}").replace("/", "\\/").replace("*", "\\*");
|
|
147
|
+
this.regex_out.push(new RegExp(rx_out, "gi"));
|
|
145
148
|
this.str_out.push(str.replace("\\", ""));
|
|
146
149
|
}
|
|
147
150
|
}
|