views:

108

answers:

2

What is the best way to add comments in erb files, if we do not want them to be generated into the html content?

+4  A: 

Use the <%# %> sequence, e.g.

<%# This is a great comment! %>
John Douthat
I used to use this format until I noticed it just raised an error on someones computer in my team (we were both using linux, but different distros), regardless I avoid it since..
vise
It's one of only a few supported ERB tags. http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html If it didn't work on their PC, they either had a typo, or they weren't using real ERB. However, I've run into issues with code like this <% for foo in bar # loop over bar %>.. This was OK in the ERB that shipped with 1.8.6, but when I switched to 1.8.7, it caused lots of problems.
John Douthat
i.e. there can't be any space between `<%` and `#`
John Douthat
How can i get textmate to generate these style of comments with apple-/
Mike
@Mike Ctrl+Shift+Period (i.e. Ctrl+GreaterThan) 4 times quickly should do it.
John Douthat
Awesome, thanks John
Mike
A: 

For Record

<%# This is a great comment! %>

<%#= This is a great comment! %>
Salil