简体   繁体   中英

How to yield a block in a partial

I have a view with this :

<%= render 'test' do %>
  test
<% end %>

And a partial like this :

<%= yield %>

When I go to the view, I want to see "test" but I see nothing.

Is there a way to yield a block inside a partial?

You need to specify that given partial behaves as a layout:

<%= render layout: 'test' do %>
  test
<% end %>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM