Open michallepicki opened 6 months ago
Hi @michallepicki, this is documented behavior: https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.HTMLFormatter.html#module-formatting
This formatter does not format Elixir expressions with do...end. The content within it will be formatted accordingly though. Therefore, the given input:
<%= live_redirect( to: "/my/path", class: "my class" ) do %> My Link <% end %>
Will be formatted to
<%= live_redirect( to: "/my/path", class: "my class" ) do %> My Link <% end %>
I don't know the reasons why it is the way it is, but I assume we'd probably accept a PR to implement this.
Thanks, I must have missed this part of the docs! Or if there are good reasons it is the way it is, maybe it should be mentioned in the docs why
Maybe @feliperenan remembers why the formatter doesn't handle such cases?
It doesn't handle such cases because we would need to build an incomplete Elixir expression and then give it to the Elixir formatter. But the formatter does not accept incomplete Elixir expressions in the first place.
Another option would be to complete the expression yourself, by attaching the end
node, and then remove it out before formatting, but there may be caveats too.
Environment
Elixir 1.16.2 (compiled with Erlang/OTP 26)
Expected behavior
I would expect the snippet to be formatted e.g. this way:
i.e. function arguments / keyword list elements to be aligned consistently with an indentation that makes some logical sense