Sha256: e3b56c0fe39f873ff0e7a83c83a76b6b13dce1890e95c756524911adeaeb3eb5

Contents?: true

Size: 1.77 KB

Versions: 14

Compression:

Stored size: 1.77 KB

Contents

module Blocks
  # TODO: Make this render order customizable
  class BlockWithHooksRenderer < AbstractRenderer
    def render(*args, &default_definition)
      with_output_buffer do
        runtime_context = RuntimeContext.new(builder, *args, &default_definition)
        if !runtime_context.skip_completely
          adjacent_blocks_renderer.render(HookDefinition::BEFORE_ALL, runtime_context)
          nesting_blocks_renderer.render(HookDefinition::AROUND_ALL, runtime_context) do
            wrapper_renderer.render(runtime_context.wrap_all, runtime_context) do
              collection_renderer.render(runtime_context) do |runtime_context|
                wrapper_renderer.render(runtime_context.wrap_each, runtime_context) do
                  nesting_blocks_renderer.render(HookDefinition::AROUND, runtime_context) do
                    adjacent_blocks_renderer.render(HookDefinition::BEFORE, runtime_context)
                    if !runtime_context.skip_content
                      wrapper_renderer.render(runtime_context.wrap_with, runtime_context) do
                        nesting_blocks_renderer.render(HookDefinition::SURROUND, runtime_context) do
                          adjacent_blocks_renderer.render(HookDefinition::PREPEND, runtime_context)
                          block_renderer.render(runtime_context)
                          adjacent_blocks_renderer.render(HookDefinition::APPEND, runtime_context)
                        end
                      end
                    end
                    adjacent_blocks_renderer.render(HookDefinition::AFTER, runtime_context)
                  end
                end
              end
            end
          end
          adjacent_blocks_renderer.render(HookDefinition::AFTER_ALL, runtime_context)
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

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