class Trenni::Template

def self.capture(*args, &block)

Returns the output produced by calling the given block.
def self.capture(*args, &block)
	scope = block.binding
	output_buffer = scope.local_variable_get(OUT)
	
	capture_buffer = String.new.force_encoding(output_buffer.encoding)
	scope.local_variable_set(OUT, capture_buffer)
	
	begin
		block.call(*args)
	ensure
		scope.local_variable_set(OUT, output_buffer)
	end
	
	return capture_buffer
end