Comment out RHTML code?


#1

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


#2

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.


#3

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 –