prettier-plugin-eex icon indicating copy to clipboard operation
prettier-plugin-eex copied to clipboard

Code within Elixir code tags not formatted

Open aidalgol opened this issue 4 years ago • 0 comments

Elixir code within <% %> or <%= %> is not formatted.

Example

Input

<nav class= "navbar">
  <div class ="navbar-group">
      <div   class="navbar-item">
    <div class="buttons" >
        <%= case  something do %>
           <% nil   -> %>
            <%= some_function( "foo", :bar, "boo", "goo", "blah", "bleh", "are we there yet?", "come ooooon!", "how much further?", "I'm borrrred!!") %>
        <% _ -> %>
              <%= boring(:bleh) %>
          <%end %>
      </div>
 </div  >
   </div>
 </nav>

Output

<nav class="navbar">
  <div class="navbar-group">
    <div class="navbar-item">
      <div class="buttons">
        <%= case  something do %>
          <% nil   -> %>
            <%= some_function( "foo", :bar, "boo", "goo", "blah", "bleh", "are we there yet?", "come ooooon!", "how much further?", "I'm borrrred!!") %>
          <% _ -> %>
            <%= boring(:bleh) %>
        <% end %>
      </div>
    </div>
  </div>
</nav>

The tags are correctly formatted, but none of the Elixir code is touched.

We probably don't want to reimplement mix format, so maybe we could pass the code snippets between prettier and the Elixir formatter?

aidalgol avatar Jun 03 '21 11:06 aidalgol