I am looking for a partial solution with several yields .
In a real example, I have this view structure:
Base application.erb ( /views/layouts/application.erb ):
<!DOCTYPE html> <head> <title>Some title</title> </head> <body> <div class="page"> <%= yield %> </div> </body> </html>
Some partial DRY my code ( /views/shared/content.erb ):
<div class="content"> <div class="sidebar"> <%= yield :sidebar %> </div> <div class="main"> <%= yield %> </div> </div>
And the controller view ( /views/home/index.erb ):
<%= render :partial => 'layouts/header' %> <%= render :partial => 'shared/navigation' %> <% # It is close to what I want to do %> <%= render :layout => 'shared/content' do %> <% content_for :sidebar do %> <%# This is will go to application.erb, not in content.erb %> <%= render :partial => 'shared/menu' %> <% end %> <%= yield %> <% end %> <%= render :partial => 'layouts/footer' %>
Thus, the main problem is to have a block of templates with many profitability areas and the ability to transmit custom html or display other partial ones.
source share