Expose HTMLFormatter.tokenize/1 as a public function#3778
Expose HTMLFormatter.tokenize/1 as a public function#3778aptinio wants to merge 1 commit intophoenixframework:mainfrom
HTMLFormatter.tokenize/1 as a public function#3778Conversation
|
Hey @aptinio, I'm afraid, but I don't think we can expose this publicly at this point (see also #3231 (comment)). We're working on colocated hooks at the moment, which may require some changes to the tokenizer, so I don't want to make its API public right now and instead give this more thought afterwards. We could maybe make it |
|
@SteffenDE, TailwindFormatter is meant to be used with PhoenixLiveView, so vendoring a particular version of PhoenixLiveView sometimes causes a problem when the user has a different version of PhoenixLiveView. Making it public, even with |
Currently, [TailwindFormatter vendors HTMLFormatter, Tokenizer and HTMLEngine](100phlecs/tailwind_formatter#35). It would be convenient for TailwindFormatter to use `HTMLFormatter.tokenize/1` directly and stay in sync with PhoenixLiveView.
ec3d529 to
e972f69
Compare
|
Fine with me. cc @josevalim |
|
My suggestion would be to add a specific |
|
That would be great @josevalim! Currently, the source code is tokenized twice, once by TailwindFormatter, which is only concerned with class attributes, then again by Phoenix.LiveView.HTMLFormatter. |
|
@aptinio would you like to try a PR? |
|
Yes. I'll give it a shot. Thanks! |
|
@josevalim, I created #3781. It includes a test but no docs yet. |
|
Closing in favor of the PR. :) |
…tter TailwindFormatter currently vendors Phoenix.LiveView.HTMLFormatter code so that it can use the private `tokenize/1` function. However, problems arise when the vendored code and the user's Phoenix.LiveView version gets out of sync. A PR has been submitted to Phoenix.LiveView team in the hopes of having this function publicly exposed: phoenixframework/phoenix_live_view#3778 Instead, a suggestion was made to add an `:attribute_formatters` config option to Phoenix.LiveView.HTMLFormatter. This has been available since Phoenix.LiveView v1.1 phoenixframework/phoenix_live_view#3781 This PR removes the vendored code and converts TailwindFormatter from a mix formatter to an attribute formatter of Phoenix.LiveView.HTMLFormatter.
TailwindFormatter currently vendors Phoenix.LiveView.HTMLFormatter code so that it can use the private `tokenize/1` function. However, problems arise when the vendored code and the user's LiveView version gets out of sync. A PR has been submitted to the Phoenix.LiveView team in the hopes of having this function publicly exposed: phoenixframework/phoenix_live_view#3778 Instead, a suggestion was made to add an `:attribute_formatters` config option to Phoenix.LiveView.HTMLFormatter. This has been available since Phoenix.LiveView v1.1 phoenixframework/phoenix_live_view#3781 This PR removes the vendored code and converts TailwindFormatter from a mix formatter to an attribute formatter of Phoenix.LiveView.HTMLFormatter.
Currently, TailwindFormatter vendors HTMLFormatter, Tokenizer and HTMLEngine.
It would be convenient for TailwindFormatter to use
HTMLFormatter.tokenize/1directly and stay in sync with PhoenixLiveView.