class ActionView::CollectionRenderer
def collection_with_template(view, template, layout, collection)
def collection_with_template(view, template, layout, collection) locals = @locals cache = {} partial_iteration = PartialIteration.new(collection.size) collection.each_with_info.map do |object, (path, as, counter, iteration)| index = partial_iteration.index locals[as] = object locals[counter] = index locals[iteration] = partial_iteration _template = (cache[path] ||= (template || find_template(path, @locals.keys + [as, counter, iteration]))) content = _template.render(view, locals) content = layout.render(view, locals) { content } if layout partial_iteration.iterate! build_rendered_template(content, _template) end end