aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/new_base/layouts.rb
diff options
context:
space:
mode:
authorCarl Lerche <carllerche@mac.com>2009-03-20 16:50:51 -0700
committerYehuda Katz <wycats@gmail.com>2009-03-23 10:23:14 -0700
commitc6123c37030b715d088860ea1ca79060659b0e3c (patch)
tree36da3c375333660c0ff41dcf113dfdf3f82c9bde /actionpack/lib/action_controller/new_base/layouts.rb
parent81e814adfad6d4bba1af5f70a5a409f6d71f8f6c (diff)
downloadrails-c6123c37030b715d088860ea1ca79060659b0e3c.tar.gz
rails-c6123c37030b715d088860ea1ca79060659b0e3c.tar.bz2
rails-c6123c37030b715d088860ea1ca79060659b0e3c.zip
Finished implementing layout for render :text
Diffstat (limited to 'actionpack/lib/action_controller/new_base/layouts.rb')
-rw-r--r--actionpack/lib/action_controller/new_base/layouts.rb23
1 files changed, 20 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/new_base/layouts.rb b/actionpack/lib/action_controller/new_base/layouts.rb
index cdf2224e39..da516c0b85 100644
--- a/actionpack/lib/action_controller/new_base/layouts.rb
+++ b/actionpack/lib/action_controller/new_base/layouts.rb
@@ -1,16 +1,33 @@
module ActionController
module Layouts
def render_to_string(options)
- options[:_layout] = options[:layout] || _layout
+ if !options.key?(:text) || options.key?(:layout)
+ options[:_layout] = options.key?(:layout) ? _layout_for_option(options[:layout]) : _layout
+ end
+
super
end
+ private
+
+ def _layout_for_option(name)
+ case name
+ when String then _layout_for_name(name)
+ when true then _layout
+ when false then nil
+ end
+ end
+
+ def _layout_for_name(name)
+ view_paths.find_by_parts(name, formats, "layouts")
+ end
+
def _layout
begin
- view_paths.find_by_parts(controller_path, formats, "layouts")
+ _layout_for_name(controller_path)
rescue ActionView::MissingTemplate
begin
- view_paths.find_by_parts("application", formats, "layouts")
+ _layout_for_name("application")
rescue ActionView::MissingTemplate
end
end