小程序xml中对t的处理修正

This commit is contained in:
Xu Chang 2024-05-14 16:51:38 +08:00
parent ef3ccd7452
commit 185982ac10
4 changed files with 19 additions and 7 deletions

View File

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

View File

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

View File

@ -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<ED extends EntityDict>(data: {
name: string;
message?: string;
opRecords: SelectOpResult<ED>;
opRecords: OpRecord<ED>[];
[A: string]: any;
}) {
const e = makeDomainException<ED>(data);

15
test.ts
View File

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