# Comment out RHTML code?

**URL:** <https://www.ruby-forum.com/t/comment-out-rhtml-code/74665>\
**Category:** Rails\
**Created:** [February 28, 2006, 12:58pm UTC](https://www.ruby-forum.com/t/comment-out-rhtml-code/74665 "2006-02-28T12:58:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [February 28, 2006, 12:58pm UTC](https://www.ruby-forum.com/t/comment-out-rhtml-code/74665/1 "2006-02-28T12:58:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [February 28, 2006, 1:18pm UTC](https://www.ruby-forum.com/t/comment-out-rhtml-code/74665/2 "2006-02-28T13:18:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [February 28, 2006, 7:28pm UTC](https://www.ruby-forum.com/t/comment-out-rhtml-code/74665/3 "2006-02-28T19:28:38Z")

</div>

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 –
