Sha256: c1fc046dd7aa76694cd26fd296d8668c4082b1c002c32e202a9e96ef275082ff

Contents?: true

Size: 620 Bytes

Versions: 4

Compression:

Stored size: 620 Bytes

Contents

# frozen_string_literal: true

module Blocks
  class AdjacentBlocksRenderer
    def self.render(hook, runtime_context)
      hooks = runtime_context.hooks_for hook
      if hooks.present?
        output_buffer = runtime_context.output_buffer
        hooks = hooks.reverse if hook.to_s.index("before") == 0 || hook.to_s.index("prepend") == 0
        hooks.each do |hook_definition|
          hook_runtime_context = runtime_context.extend_from_definition(hook_definition, &hook_definition.runtime_block)
          output_buffer << BlockWithHooksRenderer.render(hook_runtime_context)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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