erb-formatter icon indicating copy to clipboard operation
erb-formatter copied to clipboard

Ruby blocks are getting lost

Open tmaier opened this issue 1 year ago • 4 comments
trafficstars

After running erb-formatter, I see this case a couple of times in the diff:

image image

As you can see, the block within turbo_frame_tag is being lost

tmaier avatar Dec 13 '23 23:12 tmaier

I'm not sure what's going on, I tried locally modifying the with_block fixture and couldn't reproduce:

<% foo.each do |bar| %>
  <p><%= baz %></p>
<% end %>

<%= cb.with_footer(classes: 'pt-0 pb-5') do
  turbo_frame_tag "#{identifier}-footer",target: 'inner-frame' do
    paginate publications,
      params: 1
      controller: 'publications',
      action: 'index'
      outer_window: 2,
      window: 2,
      views_prefix: 'v4'
 end
end %>

is it still an issue? maybe a syntax_tree upgrade already fixed it?

elia avatar Jan 08 '24 14:01 elia

I can reproduce this issue with erb-formatter 0.7.3 and syntax_tree 6.2.0

Given the following snippet, the block will be removed.

# The entire block will be removed resulting in <% helper arg %>
<% helper arg do |api|
  api.foo
  api.bar
  api.baz
end %>

Removing the argument works:

<% helper do |api|
  api.foo
  api.bar
  api.baz
end %>

Wrapping the argument in parenthesis also works:

<% helper(arg) do |api|
  api.foo
  api.bar
  api.baz
end %>

grncdr avatar Aug 14 '24 07:08 grncdr

@grncdr thanks for picking this up. I created now some test cases in PR #61.

I hope this helps to push this forward

tmaier avatar Aug 25 '24 22:08 tmaier