Rails check if yield :area is defined in content_for

layout, ruby-on-rails, yield

Solution

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

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

Problem

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?

Original source

Related problems