I found that the <li> and </li> tags are not rendered. However, I can
solve this problem by fixing _foo.rhtml to eliminate the space between
<% and # so that it reads:
<%# here is a comment %>
<li><%= foo %></li>
My question: what's going on here? E.g., is <% # comment %> simply
incorrect syntax for including comments in a template? Or is the
problem more subtle?
I found that the <li> and </li> tags are not rendered. However, I can
solve this problem by fixing _foo.rhtml to eliminate the space between
<% and # so that it reads:
<%# here is a comment %>
<li><%= foo %></li>
My question: what's going on here? E.g., is <% # comment %> simply
incorrect syntax for including comments in a template? Or is the
problem more subtle?
<% # is invalid syntax, the only comment syntax allowed in erb is <%#
Unfortunately using <% # does not necessarily give a syntax error,
just unexpected results.
Since you started the general Ruby code block, the closing "%>" is now
the part of the comment and doesn't denote the code block end any
more. To see the difference, try:
It may work but I am not sure it is valid erb syntax. In a previous
version of Rails <% # comment %> worked. I am not sure that
<% # here is a comment
%>
can be guaranteed to work in the future. I may be wrong though.
It may work but I am not sure it is valid erb syntax. In a previous
version of Rails <% # comment %> worked. I am not sure that
<% # here is a comment
%>
can be guaranteed to work in the future. I may be wrong though.
Your probably right. And there really should be at least a warning when
it is found in a template.
It may work but I am not sure it is valid erb syntax. In a previous
version of Rails <% # comment %> worked. I am not sure that
<% # here is a comment
%>
can be guaranteed to work in the future. I may be wrong though.
Your probably right. And there really should be at least a warning when
it is found in a template.
Wow! Add this weirdness to the list of reasons to use Haml rather than
ERb (as if I needed more reasons... ).
I am with you on that one Marnen. I tried haml a little while ago and
was immediately hooked. I would highly recommend anyone who has not
tried it to have a go.