def capture_haml(*args, &block)
      buffer = eval('if defined? _hamlout then _hamlout else nil end', block.binding) || haml_buffer
      with_haml_buffer(buffer) do
        position = haml_buffer.buffer.length

        haml_buffer.capture_position = position
        value = block.call(*args)

        captured = haml_buffer.buffer.slice!(position..-1)

        if captured == '' and value != haml_buffer.buffer
          captured = (value.is_a?(String) ? value : nil)
        end

        captured
      end
    ensure
      haml_buffer.capture_position = nil
    end
def capture_haml(*args, &block)
      buffer = eval('if defined? _hamlout then _hamlout else nil end', block.binding) || haml_buffer
      with_haml_buffer(buffer) do
        position = haml_buffer.buffer.length

        haml_buffer.capture_position = position
        value = block.call(*args)

        captured = haml_buffer.buffer.slice!(position..-1)

        if captured == '' and value != haml_buffer.buffer
          captured = (value.is_a?(String) ? value : nil)
        end

        captured
      end
    ensure
      haml_buffer.capture_position = nil
    end
Captures the result of a block of Haml code,
 gets rid of the excess indentation,
 and returns it as a string.
 For example, after the following,

     .foo
       - foo = capture_haml(13) do |a|
         %p= a

 the local variable `foo` would be assigned to `"<p>13</p>\n"`.

 @param args [Array] Arguments to pass into the block
 @yield [args] A block of Haml code that will be converted to a string
 @yieldparam args [Array] `args`