forked from ruby-syntax-tree/syntax_tree-xml
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
bugSomething isn't workingSomething isn't working
Description
ERB-snippet
<ul>
<% if @items.each do |i|%>
<li><%= i %></li>
<% end.blank? %>
<li>No items</li>
<% end %>
</ul>Expected formatting
<ul>
<% if @items.each do |i|%>
<li><%= i %></li>
<% end.blank? %>
<li>No items</li>
<% end %>
</ul>Actual formatting
Error: syntax error, unexpected `end'
> 1 | <ul>
| ^
2 | <% if @items.each do |i|%>
3 | <li><%= i %></li>
4 | <% end.blank? %>Comment
This may be an anti-pattern but it's valid ERB. Instead of checking the size of @items directly, you can check if the each block rendered anything and if not (i.e. .blank? is true) then you render the fallback.
If this pattern can't be supported, it would be nice if the syntax error pointed to a better spot at least.
Versions
syntax_tree: 6.1.1
syntax_tree-erb: 0.10.5
davidwessman
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working