aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/abstract/layouts.rb6
-rw-r--r--actionpack/lib/action_controller/new_base/layouts.rb21
-rw-r--r--actionpack/lib/action_view/template/template.rb2
-rw-r--r--actionpack/lib/action_view/template/text.rb4
4 files changed, 17 insertions, 16 deletions
diff --git a/actionpack/lib/action_controller/abstract/layouts.rb b/actionpack/lib/action_controller/abstract/layouts.rb
index dec394a021..b3b743d6e8 100644
--- a/actionpack/lib/action_controller/abstract/layouts.rb
+++ b/actionpack/lib/action_controller/abstract/layouts.rb
@@ -65,12 +65,12 @@ module AbstractController
# :api: plugin
# ====
# Override this to mutate the inbound layout name
- def _layout_for_name(name)
+ def _layout_for_name(name, details = {:formats => formats})
unless [String, FalseClass, NilClass].include?(name.class)
raise ArgumentError, "String, false, or nil expected; you passed #{name.inspect}"
end
- name && view_paths.find_by_parts(name, {:formats => formats}, _layout_prefix(name))
+ name && view_paths.find_by_parts(name, details, _layout_prefix(name))
end
# TODO: Decide if this is the best hook point for the feature
@@ -78,7 +78,7 @@ module AbstractController
"layouts"
end
- def _default_layout(require_layout = false)
+ def _default_layout(require_layout = false, details = {:formats => formats})
if require_layout && _action_has_layout? && !_layout
raise ArgumentError,
"There was no default layout for #{self.class} in #{view_paths.inspect}"
diff --git a/actionpack/lib/action_controller/new_base/layouts.rb b/actionpack/lib/action_controller/new_base/layouts.rb
index bf5b14c4e1..35068db770 100644
--- a/actionpack/lib/action_controller/new_base/layouts.rb
+++ b/actionpack/lib/action_controller/new_base/layouts.rb
@@ -11,23 +11,20 @@ module ActionController
end
end
- def render_to_body(options)
- # render :text => ..., :layout => ...
- # or
- # render :anything_else
+ private
+
+ def _determine_template(options)
+ super
if (!options.key?(:text) && !options.key?(:inline) && !options.key?(:partial)) || options.key?(:layout)
- options[:_layout] = options.key?(:layout) ? _layout_for_option(options[:layout]) : _default_layout
+ options[:_layout] = _layout_for_option(options.key?(:layout) ? options[:layout] : :none, options[:_template].details)
end
-
- super
end
-
- private
- def _layout_for_option(name)
+ def _layout_for_option(name, details)
case name
- when String then _layout_for_name(name)
- when true then _default_layout(true)
+ when String then _layout_for_name(name, details)
+ when true then _default_layout(true, details)
+ when :none then _default_layout(false, details)
when false, nil then nil
else
raise ArgumentError,
diff --git a/actionpack/lib/action_view/template/template.rb b/actionpack/lib/action_view/template/template.rb
index 0eedc596d2..d58f4ec19e 100644
--- a/actionpack/lib/action_view/template/template.rb
+++ b/actionpack/lib/action_view/template/template.rb
@@ -7,7 +7,7 @@ require "action_view/template/path"
module ActionView
class Template
extend TemplateHandlers
- attr_reader :source, :identifier, :handler, :mime_type
+ attr_reader :source, :identifier, :handler, :mime_type, :details
def initialize(source, identifier, handler, details)
@source = source
diff --git a/actionpack/lib/action_view/template/text.rb b/actionpack/lib/action_view/template/text.rb
index a86c3915c2..fd57b1677e 100644
--- a/actionpack/lib/action_view/template/text.rb
+++ b/actionpack/lib/action_view/template/text.rb
@@ -6,6 +6,10 @@ module ActionView #:nodoc:
@content_type = Mime[content_type]
end
+ def details
+ {:formats => [@content_type.to_sym]}
+ end
+
def identifier() self end
def render(*) self end