Sunday, January 17, 2010

[Rails] Comment syntax and strange partial rendering

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 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?

Thanks!
--
Posted via http://www.ruby-forum.com/.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate