From d0301e13f4d6e2ddf956ecf80e85384c1ea5346c Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Sat, 8 Aug 2009 12:26:58 -0300 Subject: First pass at making partial rendering an Object. More cleanup to come. --- actionpack/lib/abstract_controller/layouts.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'actionpack/lib/abstract_controller') diff --git a/actionpack/lib/abstract_controller/layouts.rb b/actionpack/lib/abstract_controller/layouts.rb index c1fb80415b..0063d54149 100644 --- a/actionpack/lib/abstract_controller/layouts.rb +++ b/actionpack/lib/abstract_controller/layouts.rb @@ -89,16 +89,18 @@ module AbstractController end def render_to_body(options = {}) + # In the case of a partial with a layout, handle the layout + # here, and make sure the view does not try to handle it + layout = options.delete(:layout) if options.key?(:partial) + response = super - if options.key?(:partial) - # This is a little bit messy. We need to explicitly handle partial - # layouts here since the core lookup logic is in the view, but - # we need to determine the layout based on the controller - if options.key?(:layout) - layout = _layout_for_option(options[:layout], options[:_template].details) - response = layout.render(view_context, options[:locals]) { response } - end + # This is a little bit messy. We need to explicitly handle partial + # layouts here since the core lookup logic is in the view, but + # we need to determine the layout based on the controller + if layout + layout = _layout_for_option(layout, options[:_template].details) + response = layout.render(view_context, options[:locals] || {}) { response } end response -- cgit v1.2.3