5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/blocks/renderers/block_renderer.rb', line 5
def self.render(runtime_context)
output_buffer = runtime_context.output_buffer
render_item = runtime_context.render_item
if render_item.is_a?(String) || render_item.respond_to?(:to_partial_path)
output_buffer << PartialRenderer.render(runtime_context)
elsif render_item.is_a?(Proc)
args = runtime_context.runtime_args + [runtime_context.to_hash]
if runtime_context.runtime_block && runtime_context.runtime_block != render_item
args = args.unshift runtime_context.runtime_block
end
output_buffer << runtime_context.capture(*args, &render_item)
elsif render_item.is_a?(Method)
args = runtime_context.runtime_args + [runtime_context.to_hash]
if render_item.arity >= 0
args = args[0, render_item.arity]
end
output_buffer << runtime_context.capture do
render_item.call(*args, &runtime_context.runtime_block)
end
end
end
|