Sha256: f8220a9b7af89d83087a30801f9b4163508484a44013d0915e4c779f7b1c468a

Contents?: true

Size: 566 Bytes

Versions: 14

Compression:

Stored size: 566 Bytes

Contents

module Blocks
  class CollectionRenderer < AbstractRenderer
    def render(runtime_context)
      collection = runtime_context.collection
      if collection
        object_name = runtime_context.as || :object
        collection.each_with_index do |item, index|
          item_runtime_context = runtime_context.merge(object_name => item, current_index: index)
          item_runtime_context.runtime_args = [item] + item_runtime_context.runtime_args
          yield item_runtime_context
        end
      else
        yield runtime_context
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
blocks-3.0.4 lib/blocks/renderers/collection_renderer.rb
blocks-3.0.3 lib/blocks/renderers/collection_renderer.rb
blocks-3.0.2 lib/blocks/renderers/collection_renderer.rb
blocks-3.0.1 lib/blocks/renderers/collection_renderer.rb
blocks-3.0.0 lib/blocks/renderers/collection_renderer.rb
blocks-3.0.0.rc9 lib/blocks/renderers/collection_renderer.rb
blocks-3.0.0.rc8 lib/blocks/renderers/collection_renderer.rb
blocks-3.0.0.rc7 lib/blocks/renderers/collection_renderer.rb
blocks-3.0.0.rc6 lib/blocks/renderers/collection_renderer.rb
blocks-3.0.0.rc5 lib/blocks/renderers/collection_renderer.rb
blocks-3.0.0.rc4 lib/blocks/renderers/collection_renderer.rb
blocks-3.0.0.rc3 lib/blocks/renderers/collection_renderer.rb
blocks-3.0.0.rc2 lib/blocks/renderers/collection_renderer.rb
blocks-3.0.0.rc1 lib/blocks/renderers/collection_renderer.rb