Forum: Ruby on Rails Comment out RHTML code?

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.
Pat M. (Guest)
on 2006-02-28 13:58
(Received via mailing list)
I'd like to be able to comment out a few lines of RHTML code easily.
With HTML you can just surround the code in <!-- ... -->, but if you
do that with the RHTML, it still gets executed, then the resulting
HTML is commented out.  Sometimes I'd like to be able to leave the
code in but not have it evaluated..usually just for quick tests, but
sometimes I want to take the snippet out for a few days.  As it is, I
have to copy it and save it in a new file.  Is it possible to just
comment it out somehow so it doesn't get eval'ed?

Pat
Rob N. (Guest)
on 2006-02-28 14:18
You can use # to comment out lines of Ruby code.

If you doing it within RHTML:

<%= #item.unit_price%>

causes an error

but

<%#= item.unit_price%>

prevents the unit price of the item being displayed.
Dean (Guest)
on 2006-02-28 20:28
(Received via mailing list)
Pat M. wrote:
> I'd like to be able to comment out a few lines of RHTML code easily.
> With HTML you can just surround the code in <!-- ... -->, but if you
> do that with the RHTML, it still gets executed, then the resulting
> HTML is commented out.  Sometimes I'd like to be able to leave the
> code in but not have it evaluated..usually just for quick tests, but
> sometimes I want to take the snippet out for a few days.  As it is, I
> have to copy it and save it in a new file.  Is it possible to just
> comment it out somehow so it doesn't get eval'ed?
>
> Pat

Try:

<%= # this won't get executed
%>

--Dean
--
Take your time, take your chances
[3278.7 km, 273.4] Apparent Rennerian
--------------------------------------------------------------------------------
It matters not how strait the gate, / How charged with punishments the
scroll,
I am the master of my fate: / I am the captain of my soul.        --
Invictus --
                                                           -- William E
Henley --
This topic is locked and can not be replied to.