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