Forum: Ruby on Rails difference between <%= end %> <%= end -%>

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
rita (Guest)
on 2007-03-13 14:50
(Received via mailing list)
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?
Chris M. (Guest)
on 2007-03-13 15:22
(Received via mailing list)
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...<br />
2...<br />
1...<br />
Merry Christmas!

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

3...<br />
2...<br />
1...<br />

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 <br /> tag which makes your browser
display a newline when it renders the HTML.

Chris
rita (Guest)
on 2007-03-14 10:16
(Received via mailing list)
On Mar 13, 6:21 pm, "Chris M." <removed_email_address@domain.invalid> wrote:
> >     Merry Christmas!
>
> generated HTML code, not the <br /> 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...<br />
2...<br />
1...<br />
Merry Christmas!

Rita.
Jamal S. (Guest)
on 2007-03-14 12:28
rita wrote:
> On Mar 13, 6:21 pm, "Chris M." <removed_email_address@domain.invalid> wrote:
>> >     Merry Christmas!
>>
>> generated HTML code, not the <br /> 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...<br />
> 2...<br />
> 1...<br />
> Merry Christmas!
>
> Rita.

ok try this

the -%> would remove the \n in the HTML tag, you shouldn't worry about
:)
This topic is locked and can not be replied to.