diff --git a/middleman-core/fixtures/nested-layout-app/source/another.html.markdown b/middleman-core/fixtures/nested-layout-app/source/another.html.markdown new file mode 100644 index 00000000..562ceae5 --- /dev/null +++ b/middleman-core/fixtures/nested-layout-app/source/another.html.markdown @@ -0,0 +1,7 @@ +--- +title: "New Article Title" +date: 2011-01-01 +layout: inner +--- + +The Article Content diff --git a/middleman-core/lib/middleman-core/core_extensions/rendering.rb b/middleman-core/lib/middleman-core/core_extensions/rendering.rb index 41dd43b8..e848aaba 100644 --- a/middleman-core/lib/middleman-core/core_extensions/rendering.rb +++ b/middleman-core/lib/middleman-core/core_extensions/rendering.rb @@ -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 @@ -400,4 +407,4 @@ module Middleman end end end -end \ No newline at end of file +end diff --git a/middleman-more/features/nested_layouts.feature b/middleman-more/features/nested_layouts.feature index 124e684d..f475d9d1 100644 --- a/middleman-more/features/nested_layouts.feature +++ b/middleman-more/features/nested_layouts.feature @@ -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"