Module: Primer::ExperimentalRenderHelpers::InstanceMethods
- Defined in:
- app/lib/primer/experimental_render_helpers.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#evaluate_block(*args, **kwargs, &block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/lib/primer/experimental_render_helpers.rb', line 12 def evaluate_block(*args, **kwargs, &block) # Prevent double renders by using the capture method on the component # that originally received the block. # # Handle blocks that originate from C code such as `&:method` by checking # source_location. Such blocks don't allow access to their receiver. return unless block return yield(*args, **kwargs) if block&.source_location.nil? block_context = block.binding.receiver if block_context.class < ActionView::Base block_context.capture(*args, &block) else capture(*args, &block) end end |