def render(scope = Object.new, locals = {}, &block)
      parent = scope.instance_variable_defined?(:@haml_buffer) ? scope.instance_variable_get(:@haml_buffer) : nil
      buffer = Haml::Buffer.new(parent, @options.for_buffer)

      if scope.is_a?(Binding)
        scope_object = eval("self", scope)
        scope = scope_object.instance_eval{binding} if block_given?
      else
        scope_object = scope
        scope = scope_object.instance_eval{binding}
      end

      set_locals(locals.merge(:_hamlout => buffer, :_erbout => buffer.buffer), scope, scope_object)

      scope_object.extend(Haml::Helpers)
      scope_object.instance_variable_set(:@haml_buffer, buffer)
      begin
        eval(@temple_engine.precompiled_with_return_value, scope, @options.filename, @options.line)
      rescue ::SyntaxError => e
        raise SyntaxError, e.message
      end
    ensure
      # Get rid of the current buffer
      scope_object.instance_variable_set(:@haml_buffer, buffer.upper) if buffer
    end
def render(scope = Object.new, locals = {}, &block)
      parent = scope.instance_variable_defined?(:@haml_buffer) ? scope.instance_variable_get(:@haml_buffer) : nil
      buffer = Haml::Buffer.new(parent, @options.for_buffer)

      if scope.is_a?(Binding)
        scope_object = eval("self", scope)
        scope = scope_object.instance_eval{binding} if block_given?
      else
        scope_object = scope
        scope = scope_object.instance_eval{binding}
      end

      set_locals(locals.merge(:_hamlout => buffer, :_erbout => buffer.buffer), scope, scope_object)

      scope_object.extend(Haml::Helpers)
      scope_object.instance_variable_set(:@haml_buffer, buffer)
      begin
        eval(@temple_engine.precompiled_with_return_value, scope, @options.filename, @options.line)
      rescue ::SyntaxError => e
        raise SyntaxError, e.message
      end
    ensure
      # Get rid of the current buffer
      scope_object.instance_variable_set(:@haml_buffer, buffer.upper) if buffer
    end
Processes the template and returns the result as a string.

 `scope` is the context in which the template is evaluated.
 If it's a `Binding`, Haml uses it as the second argument to `Kernel#eval`;
 otherwise, Haml just uses its `#instance_eval` context.

 Note that Haml modifies the evaluation context
 (either the scope object or the `self` object of the scope binding).
 It extends {Haml::Helpers}, and various instance variables are set
 (all prefixed with `haml_`).
 For example:

     s = "foobar"
     Haml::Engine.new("%p= upcase").render(s) #=> "<p>FOOBAR</p>"

     # s now extends Haml::Helpers
     s.respond_to?(:html_attrs) #=> true

 `locals` is a hash of local variables to make available to the template.
 For example:

     Haml::Engine.new("%p= foo").render(Object.new, :foo => "Hello, world!") #=> "<p>Hello, world!</p>"

 If a block is passed to render,
 that block is run when `yield` is called
 within the template.

 Due to some Ruby quirks,
 if `scope` is a `Binding` object and a block is given,
 the evaluation context may not be quite what the user expects.
 In particular, it's equivalent to passing `eval("self", scope)` as `scope`.
 This won't have an effect in most cases,
 but if you're relying on local variables defined in the context of `scope`,
 they won't work.

 @param scope [Binding, Object] The context in which the template is evaluated
 @param locals [{Symbol => Object}] Local variables that will be made available
   to the template
 @param block [#to_proc] A block that can be yielded to within the template
 @return [String] The rendered template