Module: Munge::Helpers::Capture
- Defined in:
- lib/munge/helpers/capture.rb
Instance Method Summary collapse
Instance Method Details
#append_to_erbout(block_binding, text) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/munge/helpers/capture.rb', line 19 def append_to_erbout(block_binding, text) if block_binding.local_variable_defined?(:_erbout) original_erbout = block_binding.local_variable_get(:_erbout) updated_erbout = original_erbout + text block_binding.local_variable_set(:_erbout, updated_erbout) end text end |
#capture(&block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/munge/helpers/capture.rb', line 4 def capture(&block) if block.binding.local_variable_defined?(:_erbout) original_erbout = block.binding.local_variable_get(:_erbout) block.binding.local_variable_set(:_erbout, "") captured_text = block.call block.binding.local_variable_set(:_erbout, original_erbout) captured_text else block.call end end |