From 2f7c5f84e4834e49001ed565cfe45f14e120613f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 22 May 2005 11:07:09 +0000 Subject: Cure some ills discovered with the refactoring git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1351 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/layout.rb | 50 +++++++++++++----------------- 1 file changed, 21 insertions(+), 29 deletions(-) (limited to 'actionpack/lib/action_controller/layout.rb') diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb index d6423fdbff..104079efe1 100644 --- a/actionpack/lib/action_controller/layout.rb +++ b/actionpack/lib/action_controller/layout.rb @@ -3,8 +3,8 @@ module ActionController #:nodoc: def self.append_features(base) super base.class_eval do - alias_method :render_without_layout, :render - alias_method :render, :render_with_layout + alias_method :render_with_no_layout, :render + alias_method :render, :render_with_a_layout class << self alias_method :inherited_without_layout, :inherited @@ -202,43 +202,35 @@ module ActionController #:nodoc: active_layout.include?("/") ? active_layout : "layouts/#{active_layout}" if active_layout end - def xrender_with_layout(template_name = default_template_name, status = nil, layout = nil) #:nodoc: - if layout ||= active_layout and action_has_layout? - add_variables_to_assigns - logger.info("Rendering #{template_name} within #{layout}") unless logger.nil? - @content_for_layout = @template.render_file(template_name, true) - render_without_layout(layout, status) - else - render_without_layout(template_name, status) - end - end + def render_with_a_layout(options = {}, deprecated_status = nil, deprecated_layout = nil) #:nodoc: + if (layout = pick_layout(options, deprecated_layout)) && options.is_a?(Hash) && options[:text] + logger.info("Rendering #{options[:template]} within #{layout}") unless logger.nil? - def render_with_layout(options = {}, deprecated_status = nil, deprecated_layout = nil) - if (layout = active_layout_for_r(options, deprecated_layout)) && options[:text] - add_variables_to_assigns - logger.info("Rendering #{template_name} within #{layout}") unless logger.nil? + @content_for_layout = render_with_no_layout(options.merge(:layout => false)) + erase_render_results - @content_for_layout = render_without_layout(options) add_variables_to_assigns - - erase_render_results - render_without_layout(options.merge({ :text => @template.render_file(layout, true), :status => options[:status] || deprecated_status })) + render_with_no_layout(options.merge({ :text => @template.render_file(layout, true), :status => options[:status] || deprecated_status })) else - render_without_layout(options, deprecated_status) + render_with_no_layout(options, deprecated_status) end end private - def active_layout_for_r(options = {}, deprecated_layout = nil) + def pick_layout(options = {}, deprecated_layout = nil) return deprecated_layout unless deprecated_layout.nil? - case options[:layout] - when FalseClass - nil - when NilClass - active_layout if action_has_layout? - else - active_layout(options[:layout]) + if options.is_a?(Hash) + case options[:layout] + when FalseClass + nil + when NilClass + active_layout if action_has_layout? + else + active_layout(options[:layout]) + end + else + (deprecated_layout || active_layout) if action_has_layout? end end -- cgit v1.2.3