Issue with mix format - normally white space in HTML is not significant but not in this case

Our local team policy is to always run mix format on our codebase. However, it’s causing me some grief at the moment.

I have in my LiveView code:

<textarea
  id={"#{@id}-new-note"}
  placeholder="Add new note ..."
></textarea>

mix format turns this into:

<textarea
  id={"#{@id}-new-note"}
  placeholder="Add new note ..."
>
</textarea>

Unfortunately, while normally white space in HTML is not significant, in this case it will cause the textarea to have white-space as its value. Which in turn means that a browser won’t show the placeholder text.

Anyone have any suggestions? I couldn’t see an option to control this, or anything analogous to eslint-disable-next-line to temporarily turn off formatting for a specific region of code.

Fixed here: Fix HTMLFormatter for textarea by APB9785 · Pull Request #2840 · phoenixframework/phoenix_live_view · GitHub (included in v0.20.1).

6 Likes