1

I am currently learning ruby-on-rails and I noticed in the tutorial I am following that closing the syntax <% end %>.

Out of curiosity, I wanted to know why mine is showing <% end -%> with the minus sign before %. The codes are working just fine with the minus sign?

2 Answers2

0
<% end -%> 

is used to avoid line break after expression

mentosp09
  • 123
  • 1
  • 2
  • 11
-1

<% %> and <%- -%> are the same. however that <%= %> and <%= -%> are different: only the latter removes trailing whitespaces. Example :

<div>
  <%= "Hii" -%>
</div>

It will produce

<div>
  Hii</div>

and without '-' :

<div>
  Hii
</div>
  • This answer is factually incorrect. `<%-` removes leading whitespace. `-%>` removes trailing whitespace. It does not matter if the tag yields. – max Jan 28 '19 at 14:11
  • You should do some practical with that and please give some example so i can try. – Sanjay Choudhary Jan 29 '19 at 06:24