aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/render/layouts.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_view/render/layouts.rb')
-rw-r--r--actionpack/lib/action_view/render/layouts.rb17
1 files changed, 14 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/render/layouts.rb b/actionpack/lib/action_view/render/layouts.rb
index 11ff05ce5b..578f39d817 100644
--- a/actionpack/lib/action_view/render/layouts.rb
+++ b/actionpack/lib/action_view/render/layouts.rb
@@ -43,10 +43,16 @@ module ActionView
# This is the method which actually finds the layout using details in the lookup
# context object. If no layout is found, it checkes if at least a layout with
# the given name exists across all details before raising the error.
- def find_layout(layout) #:nodoc:
+ #
+ # If self.formats contains several formats, just the first one is considered in
+ # the layout lookup.
+ def find_layout(layout)
begin
- layout =~ /^\// ?
- with_fallbacks { find_template(layout) } : find_template(layout)
+ if formats.size == 1
+ _find_layout(layout)
+ else
+ update_details(:formats => self.formats.first){ _find_layout(layout) }
+ end
rescue ActionView::MissingTemplate => e
update_details(:formats => nil) do
raise unless template_exists?(layout)
@@ -54,6 +60,11 @@ module ActionView
end
end
+ def _find_layout(layout) #:nodoc:
+ layout =~ /^\// ?
+ with_fallbacks { find_template(layout) } : find_template(layout)
+ end
+
# Contains the logic that actually renders the layout.
def _render_layout(layout, locals, &block) #:nodoc:
layout.render(self, locals){ |*name| _layout_for(*name, &block) }