Rails syntax for comments in templates: is this bug understood?

Posted by brahn on Stack Overflow See other posts from Stack Overflow or by brahn
Published on 2010-01-18T04:40:26Z Indexed on 2010/05/26 14:11 UTC
Read the original article Hit count: 224

Using rails 2.3.2 I have a partial _foo.rhtml that begins with a comment as follows:

<% # here is a comment %>
<li><%= foo %></li>

When I render the partial from a view in the traditional way, e.g.

<% some_numbers = [1, 2, 3, 4, 5] %>
<ul>
<%= render :partial => "foo", :collection => some_numbers %>
</ul>

I found that the <li> and </li> tags are ommitted in the output -- i.e. the resulting HTML is

<ul> 1 2 3 4 5 </ul>

However, I can solve this problem by fixing _foo.rhtml to eliminate the space between the <% and the # so that the partial now 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?

Thanks!

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about syntax