I want to offer control over my app's navigation using multiple
yields, which worked fine on my home rails 3 installation, but at
work, I'm stuck with an app that uses 2.7, and the same approach isn't
working.

Basically, I have 3 yields: <% yield :navigation%> <% yield :sidebar
%> and regular ol' yield.

The regular one works fine, of course. However, the other two result
in certain tags being escaped: <ul>, <li>, <nav>, etc. The result is
that the tags appear as text in the display, and aren't interpreted by
the browser. I've tried the few suggestions I've found on the internet
(prefix the content_for with raw, etc), however, nothing has changed
the outcome. I should say that link_to in the content_for block is
properly handled and is not escaped, which is pretty interesting to
me.

I've reproduced the problem to a newly generated app with 1 scaffold
based class, with only minor alterations (adding the application.erb
and modifications to the index.html.erb file. Note that the navigation
content_for shows the list markup as text, but obeys the output of
link_to as markup.

application.erb:
<!DOCTYPE html>
<html>

  <body>
         <section id="page">
                <header>
                  <nav><%= raw yield :navigation %></nav>
                </header>

           <%= yield %>

         </section>
  </body>
</html>


index.html.erb:
<% content_for :navigation do %>
  <ul><li><%= link_to 'New page', new_page_path %></li></ul>
<% end %>

<h1>Listing pages</h1>

<table>
  <tr>
    <th>Title</th>
    <th>Body</th>
  </tr>

<% @pages.each do |page| %>
  <tr>
    <td><%=h page.title %></td>
    <td><%=h page.body %></td>
    <td><%= link_to 'Show', page %></td>
    <td><%= link_to 'Edit', edit_page_path(page) %></td>
    <td><%= link_to 'Destroy', page, :confirm => 'Are you
sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>

<br />

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to