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?
  <%= render :partial => “foo”, :collection => some_numbers %>
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.
…
<% # is invalid syntax, the only comment syntax allowed in erb is <%#
It is not actually invalid. Just the rest of the line is considered as
comment including %>. Working (though ugly) code was:
<% # here is a comment
%>
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… ).
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.
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:
<%
Comment
%>
Aleksey
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.