Sha256: 3fbbcb08b1900da5810cedc5a8545b95b058207ffeb45f13e0910b2e3c9a4f0b

Contents?: true

Size: 730 Bytes

Versions: 8

Compression:

Stored size: 730 Bytes

Contents

module Blocks
  class NestingBlocksRenderer < AbstractRenderer
    def render(hook, runtime_context, &block)
      block = block_for(runtime_context.block_name)
      hooks = block.try(:hooks_for, hook)
      if hooks.present?
        content_block = Proc.new { with_output_buffer { yield } }

        renderer = hooks.inject(content_block) do |inner_content, hook_definition|
          hook_runtime_context = runtime_context.extend_to_block_definition(hook_definition)
          Proc.new {
            with_output_buffer do
              block_renderer.render(inner_content, hook_runtime_context)
            end
          }
        end

        output_buffer << renderer.call
      else
        yield
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
blocks-3.0.0 lib/blocks/renderers/nesting_blocks_renderer.rb
blocks-3.0.0.rc9 lib/blocks/renderers/nesting_blocks_renderer.rb
blocks-3.0.0.rc8 lib/blocks/renderers/nesting_blocks_renderer.rb
blocks-3.0.0.rc7 lib/blocks/renderers/nesting_blocks_renderer.rb
blocks-3.0.0.rc6 lib/blocks/renderers/nesting_blocks_renderer.rb
blocks-3.0.0.rc5 lib/blocks/renderers/nesting_blocks_renderer.rb
blocks-3.0.0.rc4 lib/blocks/renderers/nesting_blocks_renderer.rb
blocks-3.0.0.rc3 lib/blocks/renderers/nesting_blocks_renderer.rb