How do we add comments in erb files, if we do not want them to be generated into the html content?
For Record
<%# This is a great comment! %>
<%#= This is a great comment! %>
In my text editor, i run command + /
(sublime-text shortcut). It will be like this.
<%
=begin%>
Here is the comment
<%
=end%>
It doesn't look simply, but it works.
I doesn't work in the Controllers files, I had to put it between slashes
/ comment here.... /
Since .erb is by definition "embedded ruby", you can embed every ruby code between: <%=
and the other: %>
, typically all written in one line. In addition, ruby one-line comments start always with #
, so the <%=# Comment %>
style matches perfectly with both pure-ruby and erb styles for one-line comments.
For block comments:
<% if false %>
code to be commented out...
<% end %>
I have a Windows setup, and this <%-# %> sequence is the only one that works for me:
Example:
<%-# This is a sample comment! %>