Ryan Kanno: The diary of an Enginerd in Hawaii

Everything you’ve ever thought, but never had the balls to say.

ERB block comments in RHTML templates using Ruby on Rails

This blog is simply a reminder to myself more than anything else.

After searching the great Googs and reading here, here, and here about commenting out regions in your RHTML templates, I couldn’t find a (good) solution aside from the (<... if false ...>) paradigm. Using Rails 1.2.3 (I know, I know… we’re old school), to get block comments in Rails, the following worked for me, but unfortunately, still wasn’t recognized by NetBeans 6.0 (Boo!).

1
2
3
4
5
6
7
8
9
10
11
12
13
<table>
  ...
  <tbody>
    <tr id="<%= "photographer_#{photographer.id}"%>">
      <td><% 
=begin %>
<%= h photographer.first_name unless photographer.blank? %><% 
=end %>
      </td>
    </tr>
  </tbody>
  ...
</table>

Happy Coding!

Aww.. no comments. Would you like to be the first?

Please leave a reply »

Powered by Wordpress. Stalk me.