Fix nested layouts for ERB

This commit is contained in:
Ben Hollis 2012-03-24 23:41:37 -07:00 committed by Thomas Reynolds
parent deb6bddaf6
commit d8d4769702
3 changed files with 25 additions and 4 deletions

View file

@ -0,0 +1,7 @@
---
title: "New Article Title"
date: 2011-01-01
layout: inner
---
The Article Content

View file

@ -194,7 +194,7 @@ module Middleman
def render_individual_file(path, locs = {}, opts = {}, context = self, &block)
path = path.to_s
# Save current buffere for later
# Save current buffer for later
@_out_buf, _buf_was = "", @_out_buf
# Read from disk or cache the contents of the file
@ -327,9 +327,16 @@ module Middleman
# @param [String, Symbol] layout_name
# @return [void]
def wrap_layout(layout_name, &block)
content = capture(&block) if block_given?
# Save current buffer for later
@_out_buf, _buf_was = "", @_out_buf
begin
content = capture(&block) if block_given?
ensure
# Reset stored buffer
@_out_buf = _buf_was
end
layout_path = locate_layout(layout_name, current_engine)
concat render_individual_file(layout_path, @current_locs || {}, @current_opts || {}, self) { content }
@_out_buf.concat render_individual_file(layout_path, @current_locs || {}, @current_opts || {}, self) { content }
end
# The currently rendering engine

View file

@ -7,6 +7,13 @@ Feature: Allow nesting of layouts
And I should see "Inner"
And I should see "Outer"
And I should see "Master"
When I go to "/another.html"
And I should see "New Article Title"
And I should see "The Article Content"
And I should see "Inner"
And I should see "Outer"
And I should see "Master"
Scenario: YAML Front Matter isn't clobbered with nested layouts
Given the Server is running at "nested-layout-app"