instance method _render_partial_with_options

Ruby on Rails 2.12.0

Since v2.4.1 Last seen in v2.14.1 Private

Available in: v2.4.1 v2.5.0 v2.6.4 v2.7.0 v2.8.0 v2.9.1 v2.10.2 v2.11.5 v2.12.0 v2.13.0 v2.14.1

Signature

_render_partial_with_options(options)

No documentation comment.

Parameters

options req
Source
# File lib/jbuilder/jbuilder_template.rb, line 139
  def _render_partial_with_options(options)
    options.reverse_merge! locals: options.except(:partial, :as, :collection, :cached)
    options.reverse_merge! ::JbuilderTemplate.template_lookup_options
    as = options[:as]

    if as && options.key?(:collection) && CollectionRenderer.supported?
      collection = options.delete(:collection) || []
      partial = options.delete(:partial)
      options[:locals].merge!(json: self)
      collection = EnumerableCompat.new(collection) if collection.respond_to?(:count) && !collection.respond_to?(:size)

      if options.has_key?(:layout)
        ::Kernel.raise ::NotImplementedError, "The `:layout' option is not supported in collection rendering."
      end

      if options.has_key?(:spacer_template)
        ::Kernel.raise ::NotImplementedError, "The `:spacer_template' option is not supported in collection rendering."
      end

      results = CollectionRenderer
        .new(@context.lookup_context, options) { |&block| _scope(&block) }
        .render_collection_with_partial(collection, partial, @context, nil)

      array! if results.respond_to?(:body) && results.body.nil?
    elsif as && options.key?(:collection) && !CollectionRenderer.supported?
      # For Rails <= 5.2:
      as = as.to_sym
      collection = options.delete(:collection)
      locals = options.delete(:locals)
      array! collection do |member|
        member_locals = locals.clone
        member_locals.merge! collection: collection
        member_locals.merge! as => member
        _render_partial options.merge(locals: member_locals)
      end
    else
      _render_partial options
    end
  end

Defined in lib/jbuilder/jbuilder_template.rb line 139 · View on GitHub · Improve this page · Find usages on GitHub

Defined in JbuilderTemplate

Type at least 2 characters to search.

↑↓ navigate · open · esc close