Methods
Constants
PARTIAL_NAMES = Hash.new {|h,k| h[k] = {} }
Public Class methods
new(view_context, options, block)
  # File actionpack/lib/action_view/render/partials.rb, line 219
def initialize(view_context, options, block)
  @view           = view_context
  @partial_names  = PARTIAL_NAMES[@view.controller.class.name]

  setup(options, block)
end
Public Instance methods
collection_with_template(template = @template)
  # File actionpack/lib/action_view/render/partials.rb, line 284
def collection_with_template(template = @template)
  segments, locals, template = [], @locals, @template

  if @options[:as]
    as = @options[:as]
    counter = "#{as}_counter".to_sym
  else
    as = template.variable_name
    counter = template.counter_name
  end

  locals[counter] = -1

  @collection.each do |object|
    locals[counter] += 1
    locals[as] = object
    segments << template.render(@view, locals)
  end

  segments
end
collection_without_template(collection_paths = @collection_paths)
  # File actionpack/lib/action_view/render/partials.rb, line 306
def collection_without_template(collection_paths = @collection_paths)
  segments, locals = [], @locals
  index, template  = -1, nil

  if @options[:as]
    as = @options[:as]
    counter = "#{as}_counter"
  end

  @collection.each_with_index do |object, i|
    template = find_template(collection_paths[i])
    locals[as || template.variable_name] = object
    locals[counter || template.counter_name] = (index += 1)

    segments << template.render(@view, locals)
  end

  @template = template
  segments
end
render()
  # File actionpack/lib/action_view/render/partials.rb, line 249
def render
  identifier = ((@template = find_template) ? @template.identifier : @path)

  if @collection
    ActiveSupport::Notifications.instrument("render_collection.action_view",
      :identifier => identifier || "collection", :count => @collection.size) do
      render_collection
    end
  else
    block, options, locals = @block, @options, @locals

    content = ActiveSupport::Notifications.instrument("render_partial.action_view",
      :identifier => identifier) do
      render_partial
    end

    if !block && (layout = options[:layout])
      content = @view._render_layout(find_template(layout), locals){ content }
    end

    content
  end
end
render_collection()
  # File actionpack/lib/action_view/render/partials.rb, line 273
def render_collection
  return nil if @collection.blank?

  if @options.key?(:spacer_template)
    spacer = find_template(@options[:spacer_template]).render(@view, @locals)
  end

  result = @template ? collection_with_template : collection_without_template
  result.join(spacer).html_safe
end
render_partial(object = @object)
  # File actionpack/lib/action_view/render/partials.rb, line 327
def render_partial(object = @object)
  locals, view, template, block = @locals, @view, @template, @block

  object ||= locals[template.variable_name]
  locals[@options[:as] || template.variable_name] = object

  template.render(view, locals) do |*name|
    view._layout_for(*name, &block)
  end
end
setup(options, block)
  # File actionpack/lib/action_view/render/partials.rb, line 226
def setup(options, block)
  partial = options[:partial]

  @options = options
  @locals  = options[:locals] || {}
  @block   = block

  if String === partial
    @object     = options[:object]
    @path       = partial
    @collection = collection
  else
    @object = partial

    if @collection = collection_from_object || collection
      paths = @collection_paths = @collection.map { |o| partial_path(o) }
      @path = paths.uniq.size == 1 ? paths.first : nil
    else
      @path = partial_path
    end
  end
end