Skip to content

Formatter: Opening and closing a tag in different <% if %> blocks #399

Description

@olivier-thatch

Input:

<% if wrap_in_dialog? %>
  <dialog>
<% end %>

<div>Stuff</div>

<% if wrap_in_dialog? %>
  </dialog>
<% end %>

Output:

<% if wrap_in_dialog? %>
  <dialog>
    <% end %>
    <div>Stuff</div>
    <% if wrap_in_dialog? %>
  </dialog>
<% end %>

Expected:

<% if wrap_in_dialog? %>
  <dialog>
<% end %>

    <div>Stuff</div>

<% if wrap_in_dialog? %>
  </dialog>
<% end %>

Playground:

https://herb-tools.dev/playground?tab=format#DwUgBAlgZmDuBOBDADgfQgO1QEwogNgPYDmA-GCAHwBQYYwuBJNoYAphthTdQxAG6UAygBcArlCjAA9LkHVe4aHCRpMOPETLda9WZuaL2nHUA

Additional context:

Kinda related to #398. This code doesn't cause any linting errors, but it is formatted incorrectly. Maybe it should actually cause a linting/parsing error? What would be good/idiomatic ERB for this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions