I found this great post explaining how you can get simple nested layouts in Rails:
# app/helpers/layouts_helper.rb
module LayoutsHelper
def parent_layout(layout)
@view_flow.set(:layout, output_buffer)
output = render(:file => "layouts/#{layout}")
self.output_buffer = ActionView::OutputBuffer.new(output)
end
end
# app/views/layouts/base.html.erb
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<%= yield %>
</body>
</html>
# app/views/layouts/application.html.erb
<div class="container">
<%= yield %>
</div>
<% parent_layout "base" %>
You will end up with
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="container">
<%= yield %>
</div>
</body>
</html>
Now, this works with ERB. But when I change the application.html.erb to application.html.haml, the outer layout (base) is not rendered anymore.
I tried to use `@haml_buffer` instead of `self.output_buffer` in the `LayoutsHelper` but couldn't get it to work.
Can anyone help me to get this to work?
What do I need to change in the `LayoutsHelper`?
Thanks a lot!