Difference between -%> and %> in rails [duplicate]

The extra dash makes ERB not output the newline after the closing tag. There’s no difference in your example, but if you have something like this:

<div>
  <% if true -%>
  Hi
  <% end -%>
</div>

It’ll produce:

<div>
  Hi
</div>

and not this:

<div>

  Hi

</div>

Leave a Comment