summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/rude-cameras-rhyme.md5
-rw-r--r--packages/astro-parser/src/parse/read/expression.ts3
-rw-r--r--packages/astro/test/astro-basic.test.js10
-rw-r--r--packages/astro/test/fixtures/astro-basic/src/pages/forward-slash.astro13
4 files changed, 30 insertions, 1 deletions
diff --git a/.changeset/rude-cameras-rhyme.md b/.changeset/rude-cameras-rhyme.md
new file mode 100644
index 000000000..bd18704ac
--- /dev/null
+++ b/.changeset/rude-cameras-rhyme.md
@@ -0,0 +1,5 @@
+---
+'@astrojs/parser': patch
+---
+
+Bugfix: template literals in JSX tags breaking parser
diff --git a/packages/astro-parser/src/parse/read/expression.ts b/packages/astro-parser/src/parse/read/expression.ts
index 9d0d09175..c1fd6031b 100644
--- a/packages/astro-parser/src/parse/read/expression.ts
+++ b/packages/astro-parser/src/parse/read/expression.ts
@@ -84,7 +84,8 @@ function consume_tag(state: ParseState) {
switch (char) {
case "'":
- case '"': {
+ case '"':
+ case '`': {
consume_string(state, char);
break;
}
diff --git a/packages/astro/test/astro-basic.test.js b/packages/astro/test/astro-basic.test.js
index cdec77219..4f8fc3a32 100644
--- a/packages/astro/test/astro-basic.test.js
+++ b/packages/astro/test/astro-basic.test.js
@@ -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();
diff --git a/packages/astro/test/fixtures/astro-basic/src/pages/forward-slash.astro b/packages/astro/test/fixtures/astro-basic/src/pages/forward-slash.astro
new file mode 100644
index 000000000..f4df3d024
--- /dev/null
+++ b/packages/astro/test/fixtures/astro-basic/src/pages/forward-slash.astro
@@ -0,0 +1,13 @@
+---
+const slugs = ['one', 'two', 'three'];
+---
+
+<html>
+ <head>
+ </head>
+ <body>
+ {slugs.map((slug) => (
+ <a href={`/post/${slug}`}>{slug}</a>
+ ))}
+ </body>
+</html>