remove LookupContext#with_layout_format by passing formats for layouts explicitely.
This commit is contained in:
parent
be19bf3728
commit
8d7ce0f22a
@ -229,21 +229,5 @@ def locale=(value)
|
||||
|
||||
super(default_locale)
|
||||
end
|
||||
|
||||
# Uses the first format in the formats array for layout lookup.
|
||||
def with_layout_format
|
||||
if formats.size == 1
|
||||
yield
|
||||
else
|
||||
old_formats = formats
|
||||
_set_detail(:formats, formats[0,1])
|
||||
|
||||
begin
|
||||
yield
|
||||
ensure
|
||||
_set_detail(:formats, old_formats)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -47,7 +47,7 @@ def render_template(template, layout_name = nil, locals = {}) #:nodoc:
|
||||
return [super] unless layout_name && template.supports_streaming?
|
||||
|
||||
locals ||= {}
|
||||
layout = layout_name && find_layout(layout_name, locals.keys)
|
||||
layout = layout_name && find_layout(layout_name, locals.keys, [formats.first])
|
||||
|
||||
Body.new do |buffer|
|
||||
delayed_render(buffer, template, layout, @view, locals)
|
||||
|
@ -57,7 +57,7 @@ def render_template(template, layout_name = nil, locals = nil) #:nodoc:
|
||||
end
|
||||
|
||||
def render_with_layout(path, locals) #:nodoc:
|
||||
layout = path && find_layout(path, locals.keys)
|
||||
layout = path && find_layout(path, locals.keys, [formats.first])
|
||||
content = yield(layout)
|
||||
|
||||
if layout
|
||||
@ -72,25 +72,28 @@ def render_with_layout(path, locals) #:nodoc:
|
||||
# This is the method which actually finds the layout using details in the lookup
|
||||
# context object. If no layout is found, it checks if at least a layout with
|
||||
# the given name exists across all details before raising the error.
|
||||
def find_layout(layout, keys)
|
||||
with_layout_format { resolve_layout(layout, keys) }
|
||||
def find_layout(layout, keys, formats)
|
||||
resolve_layout(layout, keys, formats)
|
||||
end
|
||||
|
||||
def resolve_layout(layout, keys)
|
||||
def resolve_layout(layout, keys, formats)
|
||||
details = @details.dup
|
||||
details[:formats] = formats
|
||||
|
||||
case layout
|
||||
when String
|
||||
begin
|
||||
if layout =~ /^\//
|
||||
with_fallbacks { find_template(layout, nil, false, keys, @details) }
|
||||
with_fallbacks { find_template(layout, nil, false, keys, details) }
|
||||
else
|
||||
find_template(layout, nil, false, keys, @details)
|
||||
find_template(layout, nil, false, keys, details)
|
||||
end
|
||||
rescue ActionView::MissingTemplate
|
||||
all_details = @details.merge(:formats => @lookup_context.default_formats)
|
||||
raise unless template_exists?(layout, nil, false, keys, all_details)
|
||||
end
|
||||
when Proc
|
||||
resolve_layout(layout.call, keys)
|
||||
resolve_layout(layout.call, keys, formats)
|
||||
when FalseClass
|
||||
nil
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user