fix: bug (#5009)
Some checks failed
Build Docker Image / build-and-push (push) Waiting to run
Build Pro Image / build-and-push (push) Waiting to run
E2E / Build (push) Waiting to run
E2E / Core and plugins (push) Blocked by required conditions
E2E / plugin-workflow (push) Blocked by required conditions
E2E / plugin-workflow-approval (push) Blocked by required conditions
E2E / plugin-data-source-main (push) Blocked by required conditions
E2E / Comment on PR (push) Blocked by required conditions
NocoBase FrontEnd Test / frontend-test (18) (push) Waiting to run
NocoBase Backend Test / sqlite-test (20, false) (push) Has been cancelled
NocoBase Backend Test / sqlite-test (20, true) (push) Has been cancelled
NocoBase Backend Test / postgres-test (public, 20, nocobase, false) (push) Has been cancelled
NocoBase Backend Test / postgres-test (public, 20, nocobase, true) (push) Has been cancelled
NocoBase Backend Test / postgres-test (public, 20, public, false) (push) Has been cancelled
NocoBase Backend Test / postgres-test (public, 20, public, true) (push) Has been cancelled
NocoBase Backend Test / postgres-test (user_schema, 20, nocobase, false) (push) Has been cancelled
NocoBase Backend Test / postgres-test (user_schema, 20, nocobase, true) (push) Has been cancelled
NocoBase Backend Test / postgres-test (user_schema, 20, public, false) (push) Has been cancelled
NocoBase Backend Test / postgres-test (user_schema, 20, public, true) (push) Has been cancelled
NocoBase Backend Test / mysql-test (20, false) (push) Has been cancelled
NocoBase Backend Test / mysql-test (20, true) (push) Has been cancelled
NocoBase Backend Test / mariadb-test (20, false) (push) Has been cancelled
NocoBase Backend Test / mariadb-test (20, true) (push) Has been cancelled
Test on Windows / build (push) Has been cancelled

This commit is contained in:
Katherine 2024-08-08 13:14:06 +08:00 committed by GitHub
parent f696c67b5e
commit 9c44e0b229
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 18 deletions

View File

@ -151,9 +151,9 @@ const getVariablesData = (localVariables) => {
export async function getRenderContent(templateEngine, content, variables, localVariables, defaultParse) { export async function getRenderContent(templateEngine, content, variables, localVariables, defaultParse) {
if (content && templateEngine === 'handlebars') { if (content && templateEngine === 'handlebars') {
const renderedContent = Handlebars.compile(content);
// 处理渲染后的内容
try { try {
const renderedContent = Handlebars.compile(content);
// 处理渲染后的内容
const data = getVariablesData(localVariables); const data = getVariablesData(localVariables);
const html = renderedContent({ ...variables.ctxRef.current, ...data }); const html = renderedContent({ ...variables.ctxRef.current, ...data });
return await defaultParse(html); return await defaultParse(html);

View File

@ -87,6 +87,17 @@ const commonOptions: any = {
}, },
}); });
}; };
// 外部定义 description 的内容
const descriptionContent = (
<>
<span style={{ marginLeft: '.25em' }} className={'ant-formily-item-extra'}>
{t('Syntax references')}:
</span>
<a href="https://handlebarsjs.com/guide/" target="_blank" rel="noreferrer">
Handlebars.js
</a>
</>
);
return { return {
title: t('Edit iframe'), title: t('Edit iframe'),
@ -129,6 +140,7 @@ const commonOptions: any = {
title: '{{t("Template engine")}}', title: '{{t("Template engine")}}',
'x-component': 'Radio.Group', 'x-component': 'Radio.Group',
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
default: 'string',
enum: [ enum: [
{ value: 'string', label: t('String template') }, { value: 'string', label: t('String template') },
{ value: 'handlebars', label: t('Handlebars') }, { value: 'handlebars', label: t('Handlebars') },
@ -151,24 +163,25 @@ const commonOptions: any = {
rows: 10, rows: 10,
}, },
required: true, required: true,
description: ( description: descriptionContent,
<> 'x-reactions': [
<span style={{ marginLeft: '.25em' }} className={'ant-formily-item-extra'}> {
{t('Syntax references')}: dependencies: ['mode'],
</span> fulfill: {
<a href="https://handlebarsjs.com/guide/" target="_blank" rel="noreferrer"> state: {
Handlebars.js hidden: '{{$deps[0] === "url"}}',
</a> },
</>
),
'x-reactions': {
dependencies: ['mode'],
fulfill: {
state: {
hidden: '{{$deps[0] === "url"}}',
}, },
}, },
}, (field) => {
const { engine } = field.form.values;
if (engine === 'handlebars') {
field.description = descriptionContent;
} else {
field.description = null;
}
},
],
}, },
}, },
} as ISchema, } as ISchema,