module ActionView::Helpers::CaptureHelper

def capture_erb_with_buffer_with_haml(*args, &block)

def capture_erb_with_buffer_with_haml(*args, &block)
  if is_haml?
    capture_haml_with_buffer(*args, &block)
  else
    capture_erb_with_buffer_without_haml(*args, &block)
  end
end

def capture_with_haml(*args, &block)

def capture_with_haml(*args, &block)
  # Rails' #capture helper will just return the value of the block
  # if it's not actually in the template context,
  # as detected by the existance of an _erbout variable.
  # We've got to do the same thing for compatibility.
  block_is_haml =
    begin
      eval('_hamlout', block)
      true
    rescue
      false
    end
  if block_is_haml && is_haml?
    capture_haml(*args, &block)
  else
    capture_without_haml(*args, &block)
  end
end

def capture_with_haml(*args, &block)

def capture_with_haml(*args, &block)
  if is_haml?
    capture_haml(*args, &block)
  else
    capture_without_haml(*args, &block)
  end
end