判断wxml中代码段的正则表达式纠正

This commit is contained in:
Xu Chang 2023-08-19 10:17:26 +08:00
parent 478c945e57
commit d76abf341c
2 changed files with 3 additions and 3 deletions

View File

@ -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;

View File

@ -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'));