Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for HEEx compilation #323

Merged
merged 6 commits into from
Sep 29, 2023

Conversation

scottming
Copy link
Collaborator

@scottming scottming commented Aug 13, 2023

This PR adopts an approach that divides the compilation of HEEx into three steps. First, it focuses on the HTML portion, then the EEx part, where certain errors in EEx require evaluation to obtain, and finally, the compile_quoted step.
I think this layered approach is quite good, like peeling an onion.

Though there are some problems that I haven't thought of a good solution for now, such as

  1. In a HEEx file, when a function component does not exist, mix compile will emit an error, but how can this be achieved for single file compilation? Jose suggested that we compile the relevant ex files directly, but it seems difficult because the latest content of those files may only exist in the Document.Store of the server node.
  2. In a .ex file, like core_components.ex, how can the ~H block be compiled separately?
  3. The ~p block in a ~H block or HEEx file.

DEMO

as-you-type compilation

CleanShot.2023-08-13.at.17.51.35-trimmed.mp4

after saving

CleanShot.2023-08-13.at.17.51.35.mp4

generated by `mix new live_demo`, then add the `liveview` deps
It's like peeling an onion. When we have an HEEx file,
we first use the HTML engine to transform and compile it.
Once the part that belongs to HTML is fine,
we then use the EEx engine to transform it, evaluate it, and finally compile it.
Copy link
Collaborator

@scohen scohen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks solid.

@scottming scottming merged commit 8a4b369 into lexical-lsp:main Sep 29, 2023
6 checks passed
@scottming scottming deleted the support-heex-compilation branch September 29, 2023 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants