Method: ActionView::Helpers::CaptureHelper#with_output_buffer

Defined in:
lib/action_view/helpers/capture_helper.rb

#with_output_buffer(buf = nil) ⇒ Object

Use an alternate output buffer for the duration of the block. Defaults to a new empty string.



195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/action_view/helpers/capture_helper.rb', line 195

def with_output_buffer(buf = nil) #:nodoc:
  unless buf
    buf = ActionView::OutputBuffer.new
    if output_buffer && output_buffer.respond_to?(:encoding)
      buf.force_encoding(output_buffer.encoding)
    end
  end
  self.output_buffer, old_buffer = buf, output_buffer
  yield
  output_buffer
ensure
  self.output_buffer = old_buffer
end