Repository navigation
Conversation
GPUI only used LiveView's TagEngine.Parser to tokenize HEEx-style markup;
compilation to %GPUI.Element{} was already GPUI's own. Replace it with a
small parser for the subset GPUI supports (tags, remote/local components,
slots, {expr} attributes and children) and drop phoenix_live_view, which
also removes phoenix, phoenix_html, phoenix_pubsub, phoenix_template and
websock from the dependency tree.
Output is unchanged for every existing ~GPUI template in the repo. HTML
comments are now dropped instead of rendered as text, and unsupported
syntax (EEx tags, root attributes, value-less attributes) raises a
CompileError with the template line and column.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GPUI only used LiveView for
Phoenix.LiveView.TagEngine.Parser(a@moduledoc falseAPI) to tokenize~GPUImarkup. Compiling to%GPUI.Element{}was already GPUI's own code. This replaces that parser withGPUI.Template.Parser, a small hand-written parser for the subset GPUI supports: tags,<Remote.component>/<.local>calls,<:slot>entries, and{expr}attributes and children. With it,phoenix_live_viewis no longer a dependency, and neither arephoenix,phoenix_html,phoenix_pubsub,phoenix_templateorwebsock/websock_adapter.plugremains throughsafe_rpc.Expressions end the same way as in HEEx: braces are counted and
\{/\}escape them.Evidence
~GPUItemplate in this repository and in a downstream app (193 templates, 61 files) with both the LiveView-based compiler and the new one, ignoring source metadata. The generated code was identical for all 193.<!-- ... -->was emitted as a literal text child. After, comments are dropped.<%= %>,<div {@rest}>and value-less attributes like<div hidden>crashed the compiler withFunctionClauseErroror produced odd attributes. After, each raises aCompileErrornaming the template line and column, as do unclosed/mismatched tags and misplaced slots. New tests cover these.Compatibility
Applications that relied on HTML comments rendering as text will see that text disappear. Templates that previously compiled produce the same element trees. No schema, native, or package-version changes. Applications that depended on
phoenix_live_viewonly throughgpuineed to add it themselves.