Edge Rails gets layouts for partials

edge | layouts | partials | rails August 02 2007

Edge Rails picked up a new feature today we’ve often longed for at Collective Idea. Partials can have a layout:

<%= render :partial => "user", :layout => "admin", :collection => @users %>

This would wrap the user partial with the admin layout, which in this example adds an edit link for the admin user:

<% content_tag_for :li, user do %>
    <%= yield %> 
    <%= link_to 'Edit', edit_user_path(user) %>
<% end %>

Another cool feature in this patch is the ability to add a layout to any block in a template, for those one-off situations, or to just tidy up repeated markup:

<% render :layout => "admin", :locals => { :user => owner } do %> 
    <%= render :partial => "user", :collection => @users %>
      (owner)
<% end %>
posted by brandon | updated August 6th 01:59 PM

Speak your mind:

(Required)

(Required)


(You may use textile in your comments.)

About

I'm Brandon Keepers, a web application developer that likes beautiful code, valid markup and adherence to standards. As a part of Collective Idea in Holland, Michigan, I practice Agile software development primarily using Ruby on Rails.

-86.103171 42.785037

Contact:

more ยป

Syndicate