Conversation
dc2b345 to
27b498e
Compare
| def postprocess_tokens( | ||
| %Phoenix.LiveView.ColocatedHook{name: hook_name}, | ||
| %{hashed_name: hashed_name}, | ||
| tokens | ||
| ) do | ||
| Enum.map(tokens, fn | ||
| {:tag, name, attrs, meta} -> | ||
| {:tag, name, rewrite_hook_attrs(hook_name, hashed_name, attrs), meta} | ||
|
|
||
| {:local_component, name, attrs, meta} -> | ||
| {:local_component, name, rewrite_hook_attrs(hook_name, hashed_name, attrs), meta} | ||
|
|
||
| {:remote_component, name, attrs, meta} -> | ||
| {:remote_component, name, rewrite_hook_attrs(hook_name, hashed_name, attrs), meta} | ||
|
|
||
| other -> | ||
| other | ||
| end) | ||
| end |
There was a problem hiding this comment.
One idea I had to not have to make the tokens public is to basically treat them as opaque and have a module with functions for working with them, e.g.
def postprocess_tokens(
%Phoenix.LiveView.ColocatedHook{name: hook_name},
%{hashed_name: hashed_name},
tokens
) do
alias Phoenix.LiveView.TagExtractorHelper
TagExtractorHelper.map_tokens(tokens, fn token ->
TagExtractorHelper.rewrite_attribute(token, "phx-hook", fn _old_value -> hashed_name end)
end)
endThere was a problem hiding this comment.
I went ahead with that approach.
|
I changed the base branch to the other colocated hook branch for easier review. |
|
First and foremost, amazing work @SteffenDE! The CSS parser is amazing. 🥲 Exciting stuff, still checking out the implementation and will leave any comments if noteworthy. |
|
@greven the CSS parser/generator is not my work, but taken for demo purposes from a project linked on the elixir forum: It doesn’t have a license, so I may have to take it down on request. The plan is not to have such code in LiveView, but instead let other people implement it as libraries, while LV provides the building blocks. |
| defp remove_outdated_extracts(manifest_extracts) do | ||
| extracts = get_extracts(project_modules()) | ||
|
|
||
| case manifest_extracts -- extracts do | ||
| [] -> |
There was a problem hiding this comment.
there's one issue here in that if you include the extracted files in your git repo and then remove modules without ever compiling them, the files won't be removed
|
As someone who is interested in co-located css this is a very interesting PR 😂 |
|
We're going to rework this. |
More generic implementation for #3705.
TODO