diff --git a/middleman-core/lib/middleman-core/core_extensions/rendering.rb b/middleman-core/lib/middleman-core/core_extensions/rendering.rb index 14794718..315ea8ab 100644 --- a/middleman-core/lib/middleman-core/core_extensions/rendering.rb +++ b/middleman-core/lib/middleman-core/core_extensions/rendering.rb @@ -329,6 +329,14 @@ module Middleman def wrap_layout(layout_name, &block) # Save current buffer for later @_out_buf, _buf_was = "", @_out_buf + + layout_path = locate_layout(layout_name, current_engine) + + extension = File.extname(layout_path) + engine = extension[1..-1].to_sym + + # Store last engine for later (could be inside nested renders) + @current_engine, engine_was = engine, @current_engine begin content = if block_given? @@ -341,14 +349,6 @@ module Middleman @_out_buf = _buf_was end - layout_path = locate_layout(layout_name, current_engine) - - extension = File.extname(layout_path) - engine = extension[1..-1].to_sym - - # Store last engine for later (could be inside nested renders) - @current_engine, engine_was = engine, @current_engine - concat_content render_individual_file(layout_path, @current_locs || {}, @current_opts || {}, self) { content } ensure @current_engine = engine_was diff --git a/middleman-more/features/nested_layouts.feature b/middleman-more/features/nested_layouts.feature index 9d938397..f3b4db3f 100644 --- a/middleman-more/features/nested_layouts.feature +++ b/middleman-more/features/nested_layouts.feature @@ -6,6 +6,7 @@ Feature: Allow nesting of layouts Then I should see: """ Master +

Index Title

Outer Inner Template @@ -15,7 +16,7 @@ Feature: Allow nesting of layouts Then I should see: """ Master - New Article Title +

New Article Title

Outer Inner

The Article Content

@@ -36,10 +37,9 @@ Feature: Allow nesting of layouts Then I should see: """ Master - New Article Title +

New Article Title

Outer Inner -

The Article Content

""" diff --git a/middleman-more/fixtures/nested-layout-app/source/index.html.erb b/middleman-more/fixtures/nested-layout-app/source/index.html.erb index a1ab916e..253e9cea 100644 --- a/middleman-more/fixtures/nested-layout-app/source/index.html.erb +++ b/middleman-more/fixtures/nested-layout-app/source/index.html.erb @@ -1 +1,6 @@ +--- +title: "Index Title" +layout: inner +--- + Template \ No newline at end of file diff --git a/middleman-more/fixtures/nested-layout-app/source/layouts/master.erb b/middleman-more/fixtures/nested-layout-app/source/layouts/master.erb index fbda1cc2..fa191dd9 100644 --- a/middleman-more/fixtures/nested-layout-app/source/layouts/master.erb +++ b/middleman-more/fixtures/nested-layout-app/source/layouts/master.erb @@ -1,3 +1,3 @@ Master -<%= data.page.title %> +

<%= data.page.title %>

<%= yield %> \ No newline at end of file diff --git a/middleman-more/fixtures/nested-layout-app/source/layouts/master_haml.haml b/middleman-more/fixtures/nested-layout-app/source/layouts/master_haml.haml index bdc6ccc5..f00cbb6b 100644 --- a/middleman-more/fixtures/nested-layout-app/source/layouts/master_haml.haml +++ b/middleman-more/fixtures/nested-layout-app/source/layouts/master_haml.haml @@ -1,3 +1,3 @@ Master -= data.page.title +%h1= data.page.title = yield \ No newline at end of file