Created
May 2, 2011 20:40
-
-
Save danielres/952318 to your computer and use it in GitHub Desktop.
renderl rails helper, to make collections renderable with a layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%div.box | |
= yield |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%tr{ :class => yield(:class), :id => yield(:id) } | |
%td | |
= yield |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%li{ :class => yield(:class), :id => yield(:id) } | |
= yield :prepend | |
= yield | |
= yield :append |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- if link ||= false | |
= link_to tag, tag | |
- else | |
= tag | |
- content_for :class do | |
= dom_class tag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def renderl collection, layout, locals={} | |
for e in collection do | |
return render(:partial => e, :layout => layout, :locals => locals) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- # 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