0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

Fix parser error on forward slash (#469)

Fixes #407
This commit is contained in:
Drew Powers 2021-06-16 13:26:38 -06:00 committed by GitHub
parent a0d94cb633
commit 7f8d5869c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/parser': patch
---
Bugfix: template literals in JSX tags breaking parser

View file

@ -84,7 +84,8 @@ function consume_tag(state: ParseState) {
switch (char) {
case "'":
case '"': {
case '"':
case '`': {
consume_string(state, char);
break;
}

View file

@ -64,4 +64,14 @@ Basics('Build does not include HMR client', async ({ build, readFile }) => {
assert.equal(hmrPortScript.length, 0, 'No script setting the websocket port');
});
Basics('Allows forward-slashes in mustache tags (#407)', async ({ runtime }) => {
const result = await runtime.load('/forward-slash');
const html = result.contents;
const $ = doc(html);
assert.equal($('a[href="/post/one"]').length, 1);
assert.equal($('a[href="/post/two"]').length, 1);
assert.equal($('a[href="/post/three"]').length, 1);
});
Basics.run();

View file

@ -0,0 +1,13 @@
---
const slugs = ['one', 'two', 'three'];
---
<html>
<head>
</head>
<body>
{slugs.map((slug) => (
<a href={`/post/${slug}`}>{slug}</a>
))}
</body>
</html>