From 185982ac10bf6c6368a2e3b0150883b2d55b0e35 Mon Sep 17 00:00:00 2001 From: Xc Date: Tue, 14 May 2024 16:51:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8Fxml=E4=B8=AD?= =?UTF-8?q?=E5=AF=B9t=E7=9A=84=E5=A4=84=E7=90=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/loaders/wxml-loader.js | 4 ++-- package.json | 3 ++- templateFiles/DependentExceptions.ts | 4 ++-- test.ts | 15 +++++++++++++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/config/loaders/wxml-loader.js b/config/loaders/wxml-loader.js index b021fea..d3d7296 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 = /(?:\{\{|%\{)(.*?)(?:\}\}?)/gm; + const codeChunkRegex = /(?:\{\{)(.*?)(?:\}\})/gm; const matches = text.match(codeChunkRegex); if (!matches) { return text; @@ -171,7 +171,7 @@ function transformCode(text, namespace, moduleName) { const { code } = transformFromAstSync(ast); assert(code.endsWith(';')); - text2 = text2.replace(codeContent, code.slice(0, code.length - 1)); + text2 = text2.replace(codeContent, code.slice(0, code.length - 1).replaceAll('\n', '')); } } return text2; diff --git a/package.json b/package.json index 306132b..f5260d9 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "build": "tsc", "dev": "tsc --watch", - "test": "cd .. && oak-cli create ttt -d" + "test": "cd .. && oak-cli create ttt -d", + "test2": "ts-node test.ts" }, "bin": { "oak-cli": "lib/index.js" diff --git a/templateFiles/DependentExceptions.ts b/templateFiles/DependentExceptions.ts index 03275fa..5316c47 100644 --- a/templateFiles/DependentExceptions.ts +++ b/templateFiles/DependentExceptions.ts @@ -1,11 +1,11 @@ import { EntityDict } from '@project/oak-app-domain'; -import { SelectOpResult } from 'oak-domain/lib/types/Entity'; +import { OpRecord } from 'oak-domain/lib/types/Entity'; import { makeException as makeDomainException } from 'oak-domain/lib/types/Exception'; export default function makeException(data: { name: string; message?: string; - opRecords: SelectOpResult; + opRecords: OpRecord[]; [A: string]: any; }) { const e = makeDomainException(data); diff --git a/test.ts b/test.ts index 8e23dff..bcf1232 100644 --- a/test.ts +++ b/test.ts @@ -1,3 +1,14 @@ -import { getPackageLatestVersion } from './src/template'; +const text = "{{t('searchByName')}}"; -console.log(getPackageLatestVersion('oak-db')); +const codeChunkRegex = /(?:\{\{)(.*?)(?:\}\})/gm; +const matches = text.match(codeChunkRegex); + +if (matches) { + matches.forEach( + (codeChunk) => { + const codeContent = codeChunk.replace(codeChunkRegex, "$1"); + + console.log(codeContent); + } + ) +} \ No newline at end of file