From c186db4e3b017ece19be805ed47664df4db84709 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 30 Jan 2023 08:31:21 +0100 Subject: [PATCH] handle backquotes in template --- frontend/src/lib/components/InputTransformForm.svelte | 8 ++++++-- frontend/src/lib/components/flows/utils.ts | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/components/InputTransformForm.svelte b/frontend/src/lib/components/InputTransformForm.svelte index 584fc07167..ad1efcab35 100644 --- a/frontend/src/lib/components/InputTransformForm.svelte +++ b/frontend/src/lib/components/InputTransformForm.svelte @@ -60,7 +60,11 @@ } if (isCodeInjection(rawValue)) { - arg.expr = getDefaultExpr(argName, previousModuleId, `\`${rawValue}\``) + arg.expr = getDefaultExpr( + argName, + previousModuleId, + `\`${rawValue.toString().replaceAll('`', '\\`')}\`` + ) arg.type = 'javascript' propertyType = 'static' } else { @@ -161,7 +165,7 @@ argName, previousModuleId, staticTemplate - ? `\`${arg?.value ?? ''}\`` + ? `\`${arg?.value.toString().replaceAll('`', '\\`') ?? ''}\`` : arg.value ? JSON.stringify(arg?.value, null, 4) : '' diff --git a/frontend/src/lib/components/flows/utils.ts b/frontend/src/lib/components/flows/utils.ts index f7e29a9061..03384103d6 100644 --- a/frontend/src/lib/components/flows/utils.ts +++ b/frontend/src/lib/components/flows/utils.ts @@ -162,7 +162,7 @@ export function codeToStaticTemplate(code?: string): string | undefined { if (lines.length == 1) { const line = lines[0].trim() if (line[0] == '`' && line.charAt(line.length - 1) == '`') { - return line.slice(1, line.length - 1) + return line.slice(1, line.length - 1).replaceAll('\\`', '`') } } return undefined