views:

112

answers:

3

"-%>" appears in some code in a tutorial I'm doing, as a delimiter of some embedded ruby, like this:

<% 5.times do |i| -%>
    <%= thumbnail_tag slideshow.slides[i] %>
<% end -%>

What does it mean? There's nothing in the book about it (Rails Up and Running)

+3  A: 

In ERB it removes any newline that follows from the output.

John Topley
A: 

This isn't a ruby delimiter, but rather a delimiter for the template language. Which templating language are you using?

mikelong
+5  A: 

The template language ERB supports <%-' and -%>' in addition to the Ruby code delimiters <%' and %>'. Adding a minus to the inner side of the delimiter strips whitespace from the HTML next to the outer side of the delimiter.

pts