diff --git a/lib/tool.js b/lib/tool.js index 05218c7..d11fb5f 100644 --- a/lib/tool.js +++ b/lib/tool.js @@ -17,15 +17,15 @@ class Tool { inc: 'include ([^\\{\\}\\(\\)]*?)', //引入其他文件 each: 'each ([^\\{\\}\\(\\)]*?)', //each循环开始 done: '/each', //each循环结束 - blockL: 'block ([^\\{\\}\\(\\)]*?)', //each循环开始 - blockR: '/block', //each循环结束 + blockL: 'block ([^\\{\\}\\(\\)]*?)', //block模块开始 + blockR: '/block', //block模块开始结束 if: 'if ([^\\{\\}\\/]*?)', //if开始 elif: 'elseif ([^\\{\\}\\/]*?)', //elseif开始 else: 'else', //else开始 fi: '/if', //if结束 var: 'var ([\\s\\S]*?)', //定义变量 echo: '=([^\\{\\}]*?)', //普通变量 - comment: '#([\\s\\S]*?)#' //引入其他文件 + comment: '#([\\s\\S]*?)#' //注释 } } @@ -278,9 +278,7 @@ class Tool { parseExtends(str) { let matches = str.match(/^/) if (!matches) { - str = str - .replace(this.__label__('blockL'), '') - .replace(this.__label__('blockR'), '') + str = str.replace(this.__label__('blockL'), '').replace(this.__label__('blockR'), '') } else { let blocks = {} // 去除所有的extends标签, 只允许有出现1次 diff --git a/lib/tool.mjs b/lib/tool.mjs index af20750..73ffabc 100644 --- a/lib/tool.mjs +++ b/lib/tool.mjs @@ -17,15 +17,15 @@ export default class Tool { inc: 'include ([^\\{\\}\\(\\)]*?)', //引入其他文件 each: 'each ([^\\{\\}\\(\\)]*?)', //each循环开始 done: '/each', //each循环结束 - blockL: 'block ([^\\{\\}\\(\\)]*?)', //each循环开始 - blockR: '/block', //each循环结束 + blockL: 'block ([^\\{\\}\\(\\)]*?)', //block模块开始 + blockR: '/block', //block模块开始结束 if: 'if ([^\\{\\}\\/]*?)', //if开始 elif: 'elseif ([^\\{\\}\\/]*?)', //elseif开始 else: 'else', //else开始 fi: '/if', //if结束 var: 'var ([\\s\\S]*?)', //定义变量 echo: '=([^\\{\\}]*?)', //普通变量 - comment: '#([\\s\\S]*?)#' //引入其他文件 + comment: '#([\\s\\S]*?)#' //注释 } } @@ -278,9 +278,7 @@ export default class Tool { parseExtends(str) { let matches = str.match(/^/) if (!matches) { - str = str - .replace(this.__label__('blockL'), '') - .replace(this.__label__('blockR'), '') + str = str.replace(this.__label__('blockL'), '').replace(this.__label__('blockR'), '') } else { let blocks = {} // 去除所有的extends标签, 只允许有出现1次