From d76abf341c86e7351b8204944a82de4c3ddb91f3 Mon Sep 17 00:00:00 2001 From: Xc Date: Sat, 19 Aug 2023 10:17:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A4=E6=96=ADwxml=E4=B8=AD=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=AE=B5=E7=9A=84=E6=AD=A3=E5=88=99=E8=A1=A8=E8=BE=BE?= =?UTF-8?q?=E5=BC=8F=E7=BA=A0=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/loaders/wxml-loader.js | 2 +- test.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/loaders/wxml-loader.js b/config/loaders/wxml-loader.js index 5e0db83..b3da525 100644 --- a/config/loaders/wxml-loader.js +++ b/config/loaders/wxml-loader.js @@ -119,7 +119,7 @@ function codeChunkIncludesT(text) { * @returns */ function transformCode(text, namespace, moduleName) { - const codeChunkRegex = /{{((\w|\W)*)}}/g; + const codeChunkRegex = /(?:\{\{|%\{)(.*?)(?:\}\}?)/gm; const matches = text.match(codeChunkRegex); if (!matches) { return text; diff --git a/test.js b/test.js index bb05262..d346ab2 100644 --- a/test.js +++ b/test.js @@ -9,7 +9,7 @@ function codeChunkIncludesT(text) { } function transformCode(text, namespace, moduleName) { - const codeChunkRegex = /{{((\w|\W)*)}}/g; + const codeChunkRegex = /(?:\{\{|%\{)(.*?)(?:\}\}?)/gm; const matches = text.match(codeChunkRegex); if (!matches) { return text; @@ -89,5 +89,5 @@ function getProjectPath(filepath) { } -console.log(transformCode('{{abc + t("abd")}}', 'ns', 'module')); +console.log(transformCode("只显示{{t('house')}}和{{t('house')}}", 'ns', 'module')); // console.log(getProjectPath('D:\\git\\taicang\\src\\pages\\home\\index.xml')); \ No newline at end of file