Commit graph

4 commits

Author SHA1 Message Date
matthewp
62924b3162 [ci] npm run format 2021-04-09 18:09:44 +00:00
Matthew Phillips
ad9c3b1d8d
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
2021-04-09 14:09:13 -04:00
matthewp
3adb9ea87c [ci] npm run format 2021-04-06 20:15:14 +00:00
Matthew Phillips
72d9ece6db
Compiler cleanup (#64)
* Compiler cleanup

This is general compiler cleanup, especially around the codegen part. Goals here were too:

1. Make it possible to compile HTML recursively (needed for future astro-in-expressions work) by moving that work into its own function.
1. Get rid of collectionItems and have compiling the HTML return just a source string.

Also not planned, this change gets rid of the different between components and pages. All Astro components compile to the same JavaScript.

* Remove unused node types
2021-04-06 16:14:42 -04:00