Skip to content

Parsing issues with yield? #51

@AliOsm

Description

@AliOsm

I have the following ERB template:

<section>
  <div class="flex flex-col pb-4 mx-auto">
    <div class="w-full bg-white rounded-lg shadow sm:max-w-lg md:mt-0 xl:p-0 dark:bg-gray-800 dark:border dark:border-gray-700">
      <div class="p-6 space-y-4 sm:p-8 md:space-y-6">
        <%= yield %>
      </div>
    </div>
  </div>
</section>

When I save it, erb-formatter VSCode extension shows the following:

Failed in line 8 ==> ERROR: Unmatched close tag, tried with ["div", "</div>"], but ["%erb%", "yield"] was on the stack

But in other templates like the following one:

<%# locals: (text:, url:, args: {}) %>

<%= link_to url, **{ class: "flex items-center text-sm font-medium text-primary-600 dark:text-primary-500 hover:underline", **args } do %>
  <%= yield %>

    <%= text %>
  <% end %>

No issues happens and the formatter works, but the formatting is not correct, I'm pasting the formatted template.

I think erb-formatter has some issues with yield with used with HTML tags.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions