Moving some stuff from the @precompiled string to the Engine#compile method.

git-svn-id: svn://hamptoncatlin.com/haml/trunk@649 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
nex3 2007-11-23 16:32:03 +00:00
parent a9418b307c
commit d09a74d0bb
2 changed files with 12 additions and 12 deletions

View File

@ -114,14 +114,13 @@ module Haml
scope = scope_object.instance_eval{binding}
end
scope_object.send(:instance_variable_set, '@_haml_locals', @options[:locals])
set_locals = @options[:locals].keys.map { |k| "#{k} = @_haml_locals[#{k.inspect}]" }.join("\n")
eval(set_locals, scope)
set_locals(@options[:locals].merge(:_hamlout => buffer, :_erbout => buffer.buffer), scope, scope_object)
scope_object.extend Haml::Helpers
scope_object.instance_eval do
extend Haml::Helpers
@haml_stack ||= Array.new
@haml_stack.push(buffer)
@haml_is_haml = true
end
begin
@ -133,9 +132,16 @@ module Haml
# Get rid of the current buffer
scope_object.instance_eval do
@haml_stack.pop
@haml_is_haml = false
end
end
def set_locals(locals, scope, scope_object)
scope_object.send(:instance_variable_set, '@_haml_locals', locals)
set_locals = locals.keys.map { |k| "#{k} = @_haml_locals[#{k.inspect}]" }.join("\n")
eval(set_locals, scope)
end
def add_exception_info(e, scope_object)
metaclass = class << e; self; end
metaclass.send(:include, Haml::Error)

View File

@ -89,12 +89,7 @@ module Haml
def precompile
@precompiled = ''
push_silent <<-END
@haml_is_haml = true
_hamlout = @haml_stack[-1]
_erbout = _hamlout.buffer
END
old_line = nil
old_index = nil
old_spaces = nil
@ -153,8 +148,7 @@ module Haml
# Close all the open tags
@template_tabs.times { close }
push_silent "@haml_is_haml = false\n"
flush_merged_text
end
# Processes and deals with lowering indentation.