class Haml::Engine
def render(scope = Object.new, locals = {}, &block)
-
(String)
- The rendered template
Parameters:
-
block
(#to_proc
) -- A block that can be yielded to within the template -
locals
({Symbol => Object}
) -- Local variables that will be made available -
scope
(Binding, Proc, Object
) -- The context in which the template is evaluated
def render(scope = Object.new, locals = {}, &block) buffer = Haml::Buffer.new(scope.instance_variable_get('@haml_buffer'), options_for_buffer) if scope.is_a?(Binding) || scope.is_a?(Proc) 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.instance_eval do extend Haml::Helpers @haml_buffer = buffer end eval(precompiled + ";" + precompiled_method_return_value, scope, @options[:filename], @options[:line]) ensure # Get rid of the current buffer scope_object.instance_eval do @haml_buffer = buffer.upper if buffer end end