Refactor TagEngine introducing TagEngine.Compiler#4125
Merged
Conversation
This commit moves the Tokenizer into the Phoenix.LiveView.TagCompiler.Tokenizer module and also adds a Parser that builds a tree similar to what the HTMLFormatter previously did. We're going to use that node tree for compiling templates in a future commit. The HTMLFormatter and HTMLAlgebra were now use this tree format.
e41555c to
8375f4f
Compare
This commit introduces a compiler for the new unified tree structure introduced in the previous commit. It changes the TagEngine to use the new compiler and also moves macro component handling to the parser. For backwards compatibility, the TagEngine still implements the EEx.Engine behaviour, but it is basically a no-op (it will still parse Elixir expressions twice!) and calls the new compiler at the end. The benefit of this is that we can now have the full tokenized template and handle macro components before compiling inner parts of the template. This allows us to more easily implement directives as explored by #4114 #4116
8375f4f to
e0b5637
Compare
josevalim
approved these changes
Jan 23, 2026
Member
josevalim
left a comment
There was a problem hiding this comment.
Looks good to me. I would only rename the new modules to TagEngine.Compiler/Parser/Tokenizer, but it is not important. Ship it!
SteffenDE
added a commit
that referenced
this pull request
Feb 20, 2026
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.
This PR refactors the TagEngine to work with the same tree we build for the HTMLFormatter. The benefit is that we have the full tree upfront which allows us to handle macro component directives (as explored by #4114, #4116). It also makes it easier to reason about the code, since all the code for handling a tag / component can be in one clause and the logic is not spread across an opening and closing clause.