Class: Blocks::AdjacentBlocksRenderer

Inherits:
AbstractRenderer show all
Defined in:
lib/blocks/renderers/adjacent_blocks_renderer.rb

Constant Summary

Constants inherited from AbstractRenderer

Blocks::AbstractRenderer::RENDERERS

Instance Attribute Summary

Attributes inherited from AbstractRenderer

#main_renderer

Instance Method Summary collapse

Methods inherited from AbstractRenderer

#capture, #initialize

Constructor Details

This class inherits a constructor from Blocks::AbstractRenderer

Instance Method Details

#render(hook, runtime_context) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/blocks/renderers/adjacent_blocks_renderer.rb', line 3

def render(hook, runtime_context)
  block = block_for(runtime_context.block_name)
  if block
    hooks = block.hooks_for hook
    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_to_block_definition(hook_definition)
      block_renderer.render(hook_runtime_context)
    end
  end
end