diff options
author | 2021-04-09 14:09:13 -0400 | |
---|---|---|
committer | 2021-04-09 14:09:13 -0400 | |
commit | ad9c3b1d8dbf1c3aff75497271347ed36ea38a0b (patch) | |
tree | 8e0aed5ea1783df8322e1db589e84f9579152ba3 /src/parser/parse/read/script.ts | |
parent | 084845f79d064626d5f5069ce7b945e3b44bdbd7 (diff) | |
download | astro-ad9c3b1d8dbf1c3aff75497271347ed36ea38a0b.tar.gz astro-ad9c3b1d8dbf1c3aff75497271347ed36ea38a0b.tar.zst astro-ad9c3b1d8dbf1c3aff75497271347ed36ea38a0b.zip |
Parse inner JSX as Astro (#67)
* Parse inner JSX as Astro
This completes the compiler changes, updating the parser so that it parses inner "JSX" as Astro. It does this by finding the start and end of HTML tags and feeds that back into the parser.
The result is a structure like this:
```
{
type: 'MustacheTag',
expression: [
{
type: 'Expression',
codeStart: 'colors.map(color => (',
codeEnd: '}}'
children: [ {
type: 'Fragment',
children: [ {
type: 'Element',
name: 'div'
} ]
} ]
}
]
}
```
There is a new Node type, `Expression`. Note that `MustacheTag` remains in the tree, all it contains is an Expression though. I could spend some time trying to remove it, there's just a few places that expect it to exist.
* Update import to the transform
* Transform prism components into expressions
Diffstat (limited to 'src/parser/parse/read/script.ts')
-rw-r--r-- | src/parser/parse/read/script.ts | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/parser/parse/read/script.ts b/src/parser/parse/read/script.ts index 7afbfb08f..4f1d31b44 100644 --- a/src/parser/parse/read/script.ts +++ b/src/parser/parse/read/script.ts @@ -1,9 +1,9 @@ // @ts-nocheck -import * as acorn from '../acorn'; +import type { Node } from 'estree'; import { Parser } from '../index.js'; import { Script } from '../../interfaces.js'; -import { Node, Program } from 'estree'; + const script_closing_tag = '</script>'; |