Skip to content

Instantly share code, notes, and snippets.

@danielres
Created May 2, 2011 20:40
Show Gist options
  • Save danielres/952318 to your computer and use it in GitHub Desktop.
Save danielres/952318 to your computer and use it in GitHub Desktop.
renderl rails helper, to make collections renderable with a layout
%div.box
= yield
%tr{ :class => yield(:class), :id => yield(:id) }
%td
= yield
%li{ :class => yield(:class), :id => yield(:id) }
= yield :prepend
= yield
= yield :append
- if link ||= false
= link_to tag, tag
- else
= tag
- content_for :class do
= dom_class tag
module ApplicationHelper
def renderl collection, layout, locals={}
for e in collection do
return render(:partial => e, :layout => layout, :locals => locals)
end
end
end
- # usage:
= renderl @tags, 'boxed', :locals => {:foo => 'bar'}
%ul
= renderl @tags, 'list_item', { :link => false }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment