Created
August 17, 2011 22:10
-
-
Save wejrowski/1152768 to your computer and use it in GitHub Desktop.
Passing Blocks to Rails partials
This file contains hidden or 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
<% | |
# | |
# I originally needed to create a sidebar partial that had a div area where I could place custom links into. Finally found it. | |
# When I was trying to figure this out before and realized I needed to pass the view into :layout, rather than just using render 'layout'. Not sure why the block can't be passed otherwise but nonetheless... | |
# | |
# For explanation of options see | |
# http://guides.rubyonrails.org/layouts_and_rendering.html#options-for-render | |
# | |
%> | |
<%= render :layout=>'my/layout' do %> | |
<% #some extra block passing rails magic | |
%> | |
<%=link_to products_path, :class => 'button continue' do %> | |
<%= image_tag('/images/topchoice/button-arrow-left.png', :class=>'arrow') %> Shop More | |
<% end %> | |
<% end %> | |
<% | |
# Then just put this in your layout | |
%> | |
<%= yield %> |
This is great. Is there any way to achieve this effect with two blocks? Or two chunks of HTML?
Sweet! thank you
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh my god, i searched for this for a long time, it's not obvious at all, what is it not working without "layout".