Skip to content

Formatter: Scaffold Templates #673

Description

@cb341

Input:

<%# frozen_string_literal: true %>
<%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
  <%%= f.error_notification %>
  <%%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>

  <div class="form-inputs">
  <%- attributes.each do |attribute| -%>
    <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
  <%- end -%>
  </div>

  <div class="form-actions">
    <%%= f.button :submit %>
  </div>
<%% end %>

Output:

<%# frozen_string_literal: true %>

<%%= simple_form_for(@<%= singular_table_name %>

) do |f| %>

<%%= f.error_notification %>

<%%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>

<div class="form-inputs">
  <%- attributes.each do |attribute| %>
    <%%= f.<%= attribute.reference? ? :association : :input %>
    :
    <%= attribute.name %>
    %>
  <%- end %>
</div>

<div class="form-actions"><%%= f.button :submit %></div>

<%% end %>

Expected:

<%# frozen_string_literal: true %>

<%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
  <%%= f.error_notification %>
  <%%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>

  <div class="form-inputs">
  <%- attributes.each do |attribute| -%>
    <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
  <%- end -%>
  </div>

  <div class="form-actions">
    <%%= f.button :submit %>
  </div>
<%% end %>

Playground:

Playground Url

Additional context:

Scaffold templates are a bit of an edge case but I'd still expect them to be ignored by the formatter instead of being malformed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions