diff --git a/src/generators/server-side-rendering/visitors/Text.ts b/src/generators/server-side-rendering/visitors/Text.ts index 3d119ff6be..0d8d539df3 100644 --- a/src/generators/server-side-rendering/visitors/Text.ts +++ b/src/generators/server-side-rendering/visitors/Text.ts @@ -3,5 +3,5 @@ import Block from '../Block'; import { Node } from '../../../interfaces'; export default function visitText ( generator: SsrGenerator, block: Block, node: Node ) { - generator.append( node.data.replace( /\${/g, '\\${' ) ); -} \ No newline at end of file + generator.append( node.data.replace( /(\${|`|\\)/g, '\\$1' ) ); +} diff --git a/test/runtime/samples/escape-template-literals/_config.js b/test/runtime/samples/escape-template-literals/_config.js new file mode 100644 index 0000000000..df22784ba7 --- /dev/null +++ b/test/runtime/samples/escape-template-literals/_config.js @@ -0,0 +1,3 @@ +export default { + html: '`${foo}\\n`' +}; diff --git a/test/runtime/samples/escape-template-literals/main.html b/test/runtime/samples/escape-template-literals/main.html new file mode 100644 index 0000000000..4705d114d2 --- /dev/null +++ b/test/runtime/samples/escape-template-literals/main.html @@ -0,0 +1 @@ +`${foo}\n`