diff --git a/src/compiler/code_generator.ts b/src/compiler/code_generator.ts index db7918da..f8000c35 100644 --- a/src/compiler/code_generator.ts +++ b/src/compiler/code_generator.ts @@ -282,6 +282,7 @@ export class CodeGenerator { for (let block of this.blocks) { if (block.dom) { let xmlString = block.asXmlString(); + xmlString = xmlString.replace(/`/g, "\\`"); if (block.dynamicTagName) { xmlString = xmlString.replace(/^<\w+/, `<\${tag || '${block.dom.nodeName}'}`); xmlString = xmlString.replace(/\w+>$/, `\${tag || '${block.dom.nodeName}'}>`); diff --git a/tests/compiler/__snapshots__/attributes.test.ts.snap b/tests/compiler/__snapshots__/attributes.test.ts.snap index b5afa9b8..60cc10cb 100644 --- a/tests/compiler/__snapshots__/attributes.test.ts.snap +++ b/tests/compiler/__snapshots__/attributes.test.ts.snap @@ -126,6 +126,20 @@ exports[`attributes dynamic attributes 1`] = ` }" `; +exports[`attributes dynamic attributes with backticks 1`] = ` +"function anonymous(app, bdom, helpers +) { + let { text, createBlock, list, multi, html, toggler, comment } = bdom; + + let block1 = createBlock(\`
`;
expect(renderToString(template)).toBe(`
`);
@@ -33,6 +39,12 @@ describe("attributes", () => {
expect(result).toBe(``);
});
+ test("dynamic attributes with backticks", () => {
+ const template = '';
+ const result = renderToString(template);
+ expect(result).toBe(``);
+ });
+
test("two dynamic attributes", () => {
const template = ``;
const result = renderToString(template);