Created
August 8, 2012 08:02
-
-
Save simonbaird/3293321 to your computer and use it in GitHub Desktop.
block_render rails helper
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
# | |
# A trick so you can have partials that take blocks. | |
# Uses render :layout. | |
# | |
# Example: | |
# <%= block_render 'some_partial_with_a_yield', :foo => 123 do %> | |
# Any erb here... | |
# <% end %> | |
# | |
def block_render(partial_name, locals={}) | |
render :layout => partial_name, :locals => locals do | |
yield | |
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
<%= block_render 'block_thing', :foo => '123' do %> | |
stuff inside here | |
<% 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
<%= render :partial => 'thing_one', :locals => { :foo => '123' } %> | |
<%= render 'thing_one', :foo => '123' %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment