Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActionView::PartialRenderer cleanup since, we removed caching #8274

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 14 additions & 21 deletions actionpack/lib/action_view/renderer/partial_renderer.rb
Expand Up @@ -290,21 +290,18 @@ def render_collection
end end


def render_partial def render_partial
view, locals, block = @view, @locals, @block if !@block && (layout = @options[:layout])
object, as = @object, @variable

if !block && (layout = @options[:layout])
layout = find_template(layout, @template_keys) layout = find_template(layout, @template_keys)
end end


object ||= locals[as] @object ||= @locals[@variable]
locals[as] = object @locals[@variable] = @object


content = @template.render(view, locals) do |*name| content = @template.render(@view, @locals) do |*name|
view._layout_for(*name, &block) @view._layout_for(*name, &@block)
end end


content = layout.render(view, locals){ content } if layout content = layout.render(@view, @locals){ content } if layout
content content
end end


Expand Down Expand Up @@ -374,39 +371,35 @@ def find_template(path, locals)
end end


def collection_with_template def collection_with_template
view, locals, template = @view, @locals, @template
as, counter = @variable, @variable_counter

if layout = @options[:layout] if layout = @options[:layout]
layout = find_template(layout, @template_keys) layout = find_template(layout, @template_keys)
end end


index = -1 index = -1
@collection.map do |object| @collection.map do |object|
locals[as] = object @locals[@variable] = object
locals[counter] = (index += 1) @locals[@variable_counter] = (index += 1)


content = template.render(view, locals) content = @template.render(@view, @locals)
content = layout.render(view, locals) { content } if layout content = layout.render(@view, @locals) { content } if layout
content content
end end
end end


def collection_without_template def collection_without_template
view, locals, collection_data = @view, @locals, @collection_data
cache = {} cache = {}
keys = @locals.keys keys = @locals.keys


index = -1 index = -1
@collection.map do |object| @collection.map do |object|
index += 1 index += 1
path, as, counter = collection_data[index] path, as, counter = @collection_data[index]


locals[as] = object @locals[as] = object
locals[counter] = index @locals[counter] = index


template = (cache[path] ||= find_template(path, keys + [as, counter])) template = (cache[path] ||= find_template(path, keys + [as, counter]))
template.render(view, locals) template.render(@view, @locals)
end end
end end


Expand Down