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

@ -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
end