aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/abstract/renderer.rb8
-rw-r--r--actionpack/lib/action_controller/new_base/layouts.rb23
-rw-r--r--actionpack/lib/action_controller/new_base/renderer.rb10
3 files changed, 30 insertions, 11 deletions
diff --git a/actionpack/lib/action_controller/abstract/renderer.rb b/actionpack/lib/action_controller/abstract/renderer.rb
index d95158be42..5daade6109 100644
--- a/actionpack/lib/action_controller/abstract/renderer.rb
+++ b/actionpack/lib/action_controller/abstract/renderer.rb
@@ -20,8 +20,8 @@ module AbstractController
@_action_view ||= ActionView::Base.new(self.class.view_paths, {}, self)
end
- def render(name = action_name, options = {})
- self.response_body = render_to_string(name, options)
+ def render(options = {})
+ self.response_body = render_to_string(options)
end
# Raw rendering of a template.
@@ -30,7 +30,9 @@ module AbstractController
# @option _layout<String> The relative path to the layout template to use
#
# :api: plugin
- def render_to_string(name = action_name, options = {})
+ def render_to_string(options = {})
+ name = options[:_template_name] || action_name
+
template = options[:_template] || view_paths.find_by_parts(name.to_s, formats, options[:_prefix])
_render_template(template, options)
end
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
diff --git a/actionpack/lib/action_controller/new_base/renderer.rb b/actionpack/lib/action_controller/new_base/renderer.rb
index 6abf3cef11..24ca9be077 100644
--- a/actionpack/lib/action_controller/new_base/renderer.rb
+++ b/actionpack/lib/action_controller/new_base/renderer.rb
@@ -38,13 +38,13 @@ module ActionController
options[:_template] = ActionView::TextTemplate.new(_text(options))
template = nil
elsif options.key?(:template)
- template = options.delete(:template)
+ options[:_template_name] = options[:template]
elsif options.key?(:action)
- template = options.delete(:action).to_s
+ options[:_template_name] = options[:action].to_s
options[:_prefix] = _prefix
end
- super(template, options)
+ super(options)
end
private
@@ -54,7 +54,7 @@ module ActionController
end
def _text(options)
- text = options.delete(:text)
+ text = options[:text]
case text
when nil then " "
@@ -63,7 +63,7 @@ module ActionController
end
def _process_options(options)
- if status = options.delete(:status)
+ if status = options[:status]
response.status = status.to_i
end
end