Module: Bridgetown::ERBCapture

Included in:
Streamlined
Defined in:
bridgetown-core/lib/bridgetown-core/converters/erb_templates.rb

Instance Method Summary collapse

Instance Method Details

#capture(*args) ⇒ Object



64
65
66
67
68
69
70
71
72
# File 'bridgetown-core/lib/bridgetown-core/converters/erb_templates.rb', line 64

def capture(*args)
  previous_buffer_state = @_erbout
  @_erbout = OutputBuffer.new
  result = yield(*args)
  result = @_erbout.presence || result
  @_erbout = previous_buffer_state

  result.is_a?(String) ? ERB::Util.h(result) : result
end