From da0c4c5c9695e2ebe8d98b391d901b598dd293a2 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 22 May 2005 08:58:43 +0000 Subject: Deprecated all render_* methods in favor of consolidating all rendering behavior in Base#render(options). This enables more natural use of combining options, such as layouts git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1350 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/layout.rb | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 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 37dba36186..d6423fdbff 100644 --- a/actionpack/lib/action_controller/layout.rb +++ b/actionpack/lib/action_controller/layout.rb @@ -6,9 +6,6 @@ module ActionController #:nodoc: alias_method :render_without_layout, :render alias_method :render, :render_with_layout - alias_method :r_without_layout, :r - alias_method :r, :r_with_layout - class << self alias_method :inherited_without_layout, :inherited end @@ -205,7 +202,7 @@ module ActionController #:nodoc: active_layout.include?("/") ? active_layout : "layouts/#{active_layout}" if active_layout end - def render_with_layout(template_name = default_template_name, status = nil, layout = nil) #:nodoc: + 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? @@ -216,23 +213,25 @@ module ActionController #:nodoc: end end - def r_with_layout(options = {}) - if (layout = active_layout_for_r(options)) && options[:text] + 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 = r_without_layout(options) + @content_for_layout = render_without_layout(options) add_variables_to_assigns erase_render_results - r_without_layout(options.merge({ :text => @template.render_file(layout, true)})) + render_without_layout(options.merge({ :text => @template.render_file(layout, true), :status => options[:status] || deprecated_status })) else - r_without_layout(options) + render_without_layout(options, deprecated_status) end end private - def active_layout_for_r(options = {}) + def active_layout_for_r(options = {}, deprecated_layout = nil) + return deprecated_layout unless deprecated_layout.nil? + case options[:layout] when FalseClass nil @@ -244,7 +243,7 @@ module ActionController #:nodoc: end def action_has_layout? - conditions = self.class.layout_conditions + conditions = self.class.layout_conditions || {} case when conditions[:only] conditions[:only].include?(action_name) -- cgit v1.2.3