Ruby on Rails Thursday, July 28, 2011

Brent <wejrowski@...> writes:

>
> 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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment