Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When do you use <% -%> instead of <% %>

I've noticed that in some lines of rails views, this is used:

<% # Code... -%> 

instead of:

<% # Code... %>

What is the difference?

like image 358
HB. Avatar asked Nov 28 '22 16:11

HB.


1 Answers

    <ul>
    <% @posts.each do |post| -%> 
      <li><%=post.title%></li>
    <% end -%>
    </ul>

There will be no new lines in between the <ul> and first <li> and the last closing </li> and </ul>. If the - was omitted, there would.

like image 165
dylanfm Avatar answered Dec 06 '22 15:12

dylanfm