def capture_haml(*args, &block)
buffer = eval('_hamlout', block.binding) rescue haml_buffer
with_haml_buffer(buffer) do
position = haml_buffer.buffer.length
haml_buffer.capture_position = position
block.call(*args)
captured = haml_buffer.buffer.slice!(position..-1)
return captured if haml_buffer.options[:ugly]
captured = captured.split(/^/)
min_tabs = nil
captured.each do |line|
tabs = line.index(/[^ ]/) || line.length
min_tabs ||= tabs
min_tabs = min_tabs > tabs ? tabs : min_tabs
end
captured.map do |line|
line[min_tabs..-1]
end.join
end
ensure
haml_buffer.capture_position = nil
end