If i have fallowing code (<.link navigate={...} class={["class"]}, other-attr="value" ...>Show</.link>) component mix format makes it multiline and thats fine, but:
(<.link
navigate={...}
class={["class"]}
other-attr="value"
{@rest}
>
Show
</.link>)
Inner contents Show as well now has white space before and after which leads to underline expand one white space before and after
mix format still expands it to more lines. In elixir code it does not have effect, but in html those newlines/whitespaces result in factual output changes.
Yeah, I tend to agree. But also html’s default whitespace handling is really shitty and tends to require rather unreadable code in places like this just to get rid of leading or trailing whitespace around text nodes.
I don’t want to hijack this thread, but I’ve run into a similar issue with a for-loop, and I think it might be helpful to include this example here:
<%= for {graphemes, tags} <- @graphemes_with_tags do %><.text_element tags={tags} text={Enum.join(graphemes)} /><% end %>
The component is essentially a very minimal implementation of ProseMirror’s renderer. If the text_element component is on its own line, it causes additional whitespace to appear, e.g., anytime an inline style changes.
It doesn’t seem like the phx-no-format attribute would work here, either.
In a case like this, should we just not format that file? Or is there another workaround that could be added to the formatter?