Passing blocks through render('partialname')

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.

Brent <wejrowski@…> writes:

with partials.

Placing <%= yield %> in your partial will determine where blocks are
rendered:

#app/views/shared/partialname.html.erb

This is a partial heading <%= yield %>

Should result in:

This is a partial heading Misc code / text

That’s exactly what I tried. I’ve tried multiple variations too but I
can’t seem to get it.

Darn you know what it was… I was doing render ‘partialname’…
instead of render :layout=>‘partialname’

Thanks! BTW anyone know what the difference is there? ^

This works for me in rails 3.0.9:

views/layouts/application.html.erb:

<%= @title %> <%= csrf_meta_tag %>

<%= yield %>

views/users/new.html.erb:

Users#new

Find me in app/views/users/new.html.erb

<%= render :layout => ‘shared/awesome’,
:locals => {:greeting => ‘hello’} do %>

world
<% end %>

views/shared/_awesome.html.erb:

<%= greeting %>
<%= yield %>

controllers/user_controller.rb:

class UsersController < ApplicationController
def new
@title = “Sign up”
end

end

http://localhost:3000/users/new
View Source:

Sign up

Users#new

Find me in app/views/users/new.html.erb

hello
world

Brent wrote in post #1014240:

Darn you know what it was… I was doing render ‘partialname’…
instead of render :layout=>‘partialname’

Yah. That was the point of my post.