Rails check if yield :area is defined in content_for

后端 未结 6 1221
我寻月下人不归
我寻月下人不归 2020-12-22 22:23

I want to do a conditional rendering at the layout level based on the actual template has defined content_for(:an__area), any idea how to get this done?

6条回答
  •  执念已碎
    2020-12-22 22:43

    @content_for_whatever is deprecated. Use content_for? instead, like this:

    <% if content_for?(:whatever) %>
      
    <%= yield(:whatever) %>
    <% end %>

提交回复
热议问题