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)
|
super(default_locale)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
@ -47,7 +47,7 @@ def render_template(template, layout_name = nil, locals = {}) #:nodoc:
|
|||||||
return [super] unless layout_name && template.supports_streaming?
|
return [super] unless layout_name && template.supports_streaming?
|
||||||
|
|
||||||
locals ||= {}
|
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|
|
Body.new do |buffer|
|
||||||
delayed_render(buffer, template, layout, @view, locals)
|
delayed_render(buffer, template, layout, @view, locals)
|
||||||
|
@ -57,7 +57,7 @@ def render_template(template, layout_name = nil, locals = nil) #:nodoc:
|
|||||||
end
|
end
|
||||||
|
|
||||||
def render_with_layout(path, locals) #:nodoc:
|
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)
|
content = yield(layout)
|
||||||
|
|
||||||
if 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
|
# 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
|
# 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.
|
# the given name exists across all details before raising the error.
|
||||||
def find_layout(layout, keys)
|
def find_layout(layout, keys, formats)
|
||||||
with_layout_format { resolve_layout(layout, keys) }
|
resolve_layout(layout, keys, formats)
|
||||||
end
|
end
|
||||||
|
|
||||||
def resolve_layout(layout, keys)
|
def resolve_layout(layout, keys, formats)
|
||||||
|
details = @details.dup
|
||||||
|
details[:formats] = formats
|
||||||
|
|
||||||
case layout
|
case layout
|
||||||
when String
|
when String
|
||||||
begin
|
begin
|
||||||
if layout =~ /^\//
|
if layout =~ /^\//
|
||||||
with_fallbacks { find_template(layout, nil, false, keys, @details) }
|
with_fallbacks { find_template(layout, nil, false, keys, details) }
|
||||||
else
|
else
|
||||||
find_template(layout, nil, false, keys, @details)
|
find_template(layout, nil, false, keys, details)
|
||||||
end
|
end
|
||||||
rescue ActionView::MissingTemplate
|
rescue ActionView::MissingTemplate
|
||||||
all_details = @details.merge(:formats => @lookup_context.default_formats)
|
all_details = @details.merge(:formats => @lookup_context.default_formats)
|
||||||
raise unless template_exists?(layout, nil, false, keys, all_details)
|
raise unless template_exists?(layout, nil, false, keys, all_details)
|
||||||
end
|
end
|
||||||
when Proc
|
when Proc
|
||||||
resolve_layout(layout.call, keys)
|
resolve_layout(layout.call, keys, formats)
|
||||||
when FalseClass
|
when FalseClass
|
||||||
nil
|
nil
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user