Sha256: 76ef9a971c4fcdbbacee7b816d29d75cbe0a9dee26e2df72ff686e14afe9ae9f

Contents?: true

Size: 840 Bytes

Versions: 4

Compression:

Stored size: 840 Bytes

Contents

# frozen_string_literal: true

module Blocks
  class WrapperRenderer
    def self.render(wrapper, wrapper_type, runtime_context)
      output_buffer = runtime_context.output_buffer

      if wrapper.nil?
        yield

      elsif wrapper.is_a?(Proc)
        output_buffer << runtime_context.capture(
          Proc.new { runtime_context.with_output_buffer { yield } },
          *(runtime_context.runtime_args),
          runtime_context.to_hash.merge(wrapper_type: wrapper_type),
          &wrapper
        )

      else
        wrapper_runtime_context = runtime_context.extend_from_definition(
          wrapper,
          wrapper_type: wrapper_type
        ) do
          runtime_context.with_output_buffer { yield }
        end
        output_buffer << BlockWithHooksRenderer.render(wrapper_runtime_context)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
blocks-4.0.1 lib/blocks/renderers/wrapper_renderer.rb
blocks-4.0.0 lib/blocks/renderers/wrapper_renderer.rb
blocks-4.0.0.rc2 lib/blocks/renderers/wrapper_renderer.rb
blocks-4.0.0.rc1 lib/blocks/renderers/wrapper_renderer.rb