mirror of https://github.com/sveltejs/svelte
fix: Backtick now displays with templates (#9973)
* Add a test for backtick in template * Put sanitize_template_string and use it everywhere * Prettier * Add changesetpull/10008/head
parent
5dffe715d3
commit
b31946eb08
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
Fix interopability between backticks and templates
|
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* @param {string} str
|
||||
* @returns {string}
|
||||
*/
|
||||
export function sanitize_template_string(str) {
|
||||
return str.replace(/(`|\${|\\)/g, '\\$1');
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: '<div>/ $clicks: 0 `tim$es` \\</div><div>$dollars `backticks` pyramid /\\</div>'
|
||||
});
|
@ -0,0 +1,6 @@
|
||||
<div>
|
||||
/ $clicks: {0} `tim${"e"}s` \
|
||||
</div>
|
||||
<div>
|
||||
$dollars `backticks` pyramid /\
|
||||
</div>
|
Loading…
Reference in new issue