How can I capture the block that I pass through a partial. I want to
be able to do something like:
<%= render 'shared/partialname' do %>
Misc code / text
<% end %>
Then I want to display that block at a specific place in that partial.
I could do this if I created a method. But I want to know how it works
with partials.
How can I capture the block that I pass through a partial. I want to
be able to do something like:
<%= render 'shared/partialname' do %>
Misc code / text
<% end %>
Then I want to display that block at a specific place in that partial.
I could do this if I created a method. But I want to know how it works
with partials.
Placing <%= yield %> in your partial will determine where blocks are rendered:
#app/views/shared/partialname.html.erb
<h1>This is a partial heading</a>
<%= yield %>
Should result in:
<h1>This is a partial heading</a>
Misc code / text