小程序xml中对t的处理修正
This commit is contained in:
parent
ef3ccd7452
commit
185982ac10
|
|
@ -119,7 +119,7 @@ function codeChunkIncludesT(text) {
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function transformCode(text, namespace, moduleName) {
|
function transformCode(text, namespace, moduleName) {
|
||||||
const codeChunkRegex = /(?:\{\{|%\{)(.*?)(?:\}\}?)/gm;
|
const codeChunkRegex = /(?:\{\{)(.*?)(?:\}\})/gm;
|
||||||
const matches = text.match(codeChunkRegex);
|
const matches = text.match(codeChunkRegex);
|
||||||
if (!matches) {
|
if (!matches) {
|
||||||
return text;
|
return text;
|
||||||
|
|
@ -171,7 +171,7 @@ function transformCode(text, namespace, moduleName) {
|
||||||
const { code } = transformFromAstSync(ast);
|
const { code } = transformFromAstSync(ast);
|
||||||
assert(code.endsWith(';'));
|
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;
|
return text2;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"dev": "tsc --watch",
|
"dev": "tsc --watch",
|
||||||
"test": "cd .. && oak-cli create ttt -d"
|
"test": "cd .. && oak-cli create ttt -d",
|
||||||
|
"test2": "ts-node test.ts"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"oak-cli": "lib/index.js"
|
"oak-cli": "lib/index.js"
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { EntityDict } from '@project/oak-app-domain';
|
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';
|
import { makeException as makeDomainException } from 'oak-domain/lib/types/Exception';
|
||||||
|
|
||||||
export default function makeException<ED extends EntityDict>(data: {
|
export default function makeException<ED extends EntityDict>(data: {
|
||||||
name: string;
|
name: string;
|
||||||
message?: string;
|
message?: string;
|
||||||
opRecords: SelectOpResult<ED>;
|
opRecords: OpRecord<ED>[];
|
||||||
[A: string]: any;
|
[A: string]: any;
|
||||||
}) {
|
}) {
|
||||||
const e = makeDomainException<ED>(data);
|
const e = makeDomainException<ED>(data);
|
||||||
|
|
|
||||||
15
test.ts
15
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);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue