aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/layout.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-05-22 07:43:05 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-05-22 07:43:05 +0000
commit0367317dd62ecd177d57d469a4d57974b75e425b (patch)
treeaea47bdb80239ffdbd43f24387a78bc742b06b72 /actionpack/lib/action_controller/layout.rb
parentdab360e18129c8f4916b78d00d49ed9dda5ccd8a (diff)
downloadrails-0367317dd62ecd177d57d469a4d57974b75e425b.tar.gz
rails-0367317dd62ecd177d57d469a4d57974b75e425b.tar.bz2
rails-0367317dd62ecd177d57d469a4d57974b75e425b.zip
Deprecated redirect_to_path and redirect_to_url in favor of letting redirect_to do the right thing when passed either a path or url. Introduced r as a unified method for render (still under construction)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1349 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/layout.rb')
-rw-r--r--actionpack/lib/action_controller/layout.rb34
1 files changed, 31 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb
index aca3dbd797..37dba36186 100644
--- a/actionpack/lib/action_controller/layout.rb
+++ b/actionpack/lib/action_controller/layout.rb
@@ -5,6 +5,10 @@ module ActionController #:nodoc:
base.class_eval do
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
@@ -212,8 +216,33 @@ module ActionController #:nodoc:
end
end
+ def r_with_layout(options = {})
+ if (layout = active_layout_for_r(options)) && options[:text]
+ add_variables_to_assigns
+ logger.info("Rendering #{template_name} within #{layout}") unless logger.nil?
+
+ @content_for_layout = r_without_layout(options)
+ add_variables_to_assigns
+
+ erase_render_results
+ r_without_layout(options.merge({ :text => @template.render_file(layout, true)}))
+ else
+ r_without_layout(options)
+ end
+ end
+
private
-
+ def active_layout_for_r(options = {})
+ case options[:layout]
+ when FalseClass
+ nil
+ when NilClass
+ active_layout if action_has_layout?
+ else
+ active_layout(options[:layout])
+ end
+ end
+
def action_has_layout?
conditions = self.class.layout_conditions
case
@@ -225,6 +254,5 @@ module ActionController #:nodoc:
true
end
end
-
end
-end
+end \ No newline at end of file