Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'-%>' (minus sign) at the end of a ERb sequence

What's the point of using '-' (minus sign) at the end of a ERb sequence?

Example:

<% 3.times do -%>   FooBar<br /> <% end -%> Sometext 

Regardless of whether I use '-' or not, a browser renders the same output.

Thanks, Aplha.

like image 732
Alpha Sisyphus Avatar asked Dec 10 '10 10:12

Alpha Sisyphus


1 Answers

Before Rails 3, ERB adds additional spaces before and after the value when rendering the HTML content. In HTML spaces are not significant, except when you are using special tags such as <pre>.

Using the - sign forced ERB to avoid additional spaces.

This is completely useless in Rails 3.

like image 112
Simone Carletti Avatar answered Sep 24 '22 14:09

Simone Carletti