Fix wrap_layout for all know templating engines. Fixes #417

This commit is contained in:
Thomas Reynolds 2012-06-01 20:05:07 -07:00
parent 9b5d1f17d0
commit 2ab294c602
11 changed files with 68 additions and 8 deletions

View file

@ -329,19 +329,29 @@ module Middleman
def wrap_layout(layout_name, &block)
# Save current buffer for later
@_out_buf, _buf_was = "", @_out_buf
begin
content = capture(&block) if block_given?
content = if block_given?
capture_html(&block)
else
""
end
ensure
# Reset stored buffer
@_out_buf = _buf_was
end
layout_path = locate_layout(layout_name, current_engine)
if !@_out_buf
raise "wrap_layout is currently broken for this templating system"
end
@_out_buf.concat render_individual_file(layout_path, @current_locs || {}, @current_opts || {}, self) { content }
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
end
# The currently rendering engine