Class: Blocks::NestingBlocksRenderer
- Inherits:
-
AbstractRenderer
- Object
- AbstractRenderer
- Blocks::NestingBlocksRenderer
- Defined in:
- lib/blocks/renderers/nesting_blocks_renderer.rb
Constant Summary
Constants inherited from AbstractRenderer
Instance Attribute Summary
Attributes inherited from AbstractRenderer
Instance Method Summary collapse
Methods inherited from AbstractRenderer
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 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/blocks/renderers/nesting_blocks_renderer.rb', line 3 def render(hook, runtime_context) 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 |