Difference between <%= end %> <%= end -%>


#1

Hi,

I am reffering to "Agile Web D. with Rails 2nd ed B1

21.pdf" As per this book,

<% 3.downto(1) do |count| -%>
<%= count %>...<br />
<% end -%>
Merry Christmas!

The minus sign in end will supress the newline. This is not

happening in my case.
I am using ruby 1.8.4 and Rails 1.2.2

What could be the reason?


#2

On Mar 13, 12:49 pm, “rita” removed_email_address@domain.invalid wrote:

The minus sign in end will supress the newline. This is not

happening in my case.

The generated HTML code should look like this:

3…

2…

1…

Merry Christmas!

If you leave out the minus sign, it should look like this:

3…

2…

1…

Merry Christmas!

Is that what you’re seeing, or are you getting something else? Note
that the minus sign only suppresses the literal newline in the
generated HTML code, not the
tag which makes your browser
display a newline when it renders the HTML.

Chris


#3

On Mar 13, 6:21 pm, “Chris M.” removed_email_address@domain.invalid wrote:

Merry Christmas!

generated HTML code, not the
tag which makes your browser
display a newline when it renders the HTML.

Chris

Though I will keep the minus sign or remove it I am getting the output
as:

3…

2…

1…

Merry Christmas!

Rita.


#4

rita wrote:

On Mar 13, 6:21 pm, “Chris M.” removed_email_address@domain.invalid wrote:

Merry Christmas!

generated HTML code, not the
tag which makes your browser
display a newline when it renders the HTML.

Chris

Though I will keep the minus sign or remove it I am getting the output
as:

3…

2…

1…

Merry Christmas!

Rita.

ok try this

the -%> would remove the \n in the HTML tag, you shouldn’t worry about
:slight_smile: