middleman/middleman — pull request #324 by bhollis (2012-03-25 08:17:38+00:00)
Title: Fix nested layouts for ERB

This is a hacky fix for the problem in middleman/middleman-blog#35 - it looks like nested layouts didn't work when the layout uses a different template language than the main template. My patch fixes it for ERB, but the second commit shows that it still doesn't work for HAML layouts.

I played around for a few hours trying to get `@current_engine` set correctly when calling `capture` and `concat` - Padrino has special template helper classes that special-case implementations of those methods for ERB/HAML/Slim to do the right thing. However, I was never able to get something that worked right for both ERB and HAML, and I want to go to bed.

I think it'd help if `wrap_layout` just output a string instead of concatenating directly to the template buffer (see issue #323) but I'm not sure. Rails seems to get around a lot of this by standardizing on a single buffer for everything, but I haven't quite figured that out either. See https://github.com/rails/rails/blob/master/actionpack/lib/action_view/helpers/capture_helper.rb and https://github.com/nex3/haml/blob/master/lib/haml/helpers/action_view_mods.rb for where I'm looking.