1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

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

View file

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