# How to comment a block of code in RHTML file

**URL:** <https://www.ruby-forum.com/t/how-to-comment-a-block-of-code-in-rhtml-file/104650>\
**Category:** Rails\
**Created:** [May 21, 2007, 8:52am UTC](https://www.ruby-forum.com/t/how-to-comment-a-block-of-code-in-rhtml-file/104650 "2007-05-21T08:52:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lalit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/bbe5ce/32.png) [@Lalit](https://www.ruby-forum.com/u/Lalit)\
**Post date:** [May 21, 2007, 8:52am UTC](https://www.ruby-forum.com/t/how-to-comment-a-block-of-code-in-rhtml-file/104650/1 "2007-05-21T08:52:16Z")

</div>

Hi Group.

I am just starting with Ruby on Rails. I have been stuck up (not  
exactly stuck up but I need to figure this out). I need to comment a  
block of code with HTML and RUBY code. Is there any way of commenting  
an entire block of code?

Example:

 class="s\_view\_comments\_row"\>
\<%if comment.user.photo\_exists?%\>

How do I comment these 4 lines so that they are not executed when  
the .rhtml is parsed.

Lalit

---

<div class="post-metadata">

**Author:** ![Lalit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/bbe5ce/32.png) [@Lalit](https://www.ruby-forum.com/u/Lalit)\
**Post date:** [May 21, 2007, 9:00am UTC](https://www.ruby-forum.com/t/how-to-comment-a-block-of-code-in-rhtml-file/104650/2 "2007-05-21T09:00:17Z")

</div>

Hi you can do one of the follow:

or

\<%# add your commt here --\>

Good luck,

-Conrad

---

<div class="post-metadata">

**Author:** ![Lalit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/bbe5ce/32.png) [@Lalit](https://www.ruby-forum.com/u/Lalit)\
**Post date:** [May 21, 2007, 9:06am UTC](https://www.ruby-forum.com/t/how-to-comment-a-block-of-code-in-rhtml-file/104650/3 "2007-05-21T09:06:18Z")

</div>

has there shortcut?

---

<div class="post-metadata">

**Author:** ![Lalit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/bbe5ce/32.png) [@Lalit](https://www.ruby-forum.com/u/Lalit)\
**Post date:** [May 21, 2007, 9:23am UTC](https://www.ruby-forum.com/t/how-to-comment-a-block-of-code-in-rhtml-file/104650/4 "2007-05-21T09:23:21Z")

</div>

what shortcut? your IDE’s one?

On 21/05/07, guo william raym [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > or
> > 
> > >
> 
> >

–  
in03ng a.k.a inung a.k.a nursamsi a.k.a nur syamsi  
Y! in03ng

---

<div class="post-metadata">

**Author:** ![Lalit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/bbe5ce/32.png) [@Lalit](https://www.ruby-forum.com/u/Lalit)\
**Post date:** [May 21, 2007, 3:57pm UTC](https://www.ruby-forum.com/t/how-to-comment-a-block-of-code-in-rhtml-file/104650/5 "2007-05-21T15:57:07Z")

</div>

On 5/21/07, Lalit [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> \<%if comment.user.photo\_exists?%\>
> 
> How do I comment these 4 lines so that they are not executed when  
> the .rhtml is parsed.

AFAIK erb has no block commenting syntax. Here’s what I usually do  
though:

\<% if false -%\>

.... \<% end -%\>

–  
Rick O.  
[http://lighthouseapp.com](http://lighthouseapp.com)  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)
