More #precompile cleaning.
git-svn-id: svn://hamptoncatlin.com/haml/trunk@668 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
parent
199a3eae4b
commit
a2fe00a983
|
@ -116,58 +116,56 @@ END
|
||||||
end.join(';') + ';'
|
end.join(';') + ';'
|
||||||
end
|
end
|
||||||
|
|
||||||
Line = Struct.new("Line", :line, :index, :spaces, :tabs, :uline)
|
Line = Struct.new("Line", :text, :unstripped, :index, :spaces, :tabs)
|
||||||
|
|
||||||
def precompile
|
def precompile
|
||||||
@precompiled = ''
|
@precompiled = ''
|
||||||
|
|
||||||
old_line = old_index = old_spaces = old_tabs = old_uline = nil
|
old_line = Line.new
|
||||||
(@template + "\n-#").each_with_index do |line, index|
|
(@template + "\n-#").each_with_index do |text, index|
|
||||||
spaces, tabs = count_soft_tabs(line)
|
line = Line.new text.strip, text.lstrip.chomp, index
|
||||||
uline = line.lstrip.chomp
|
line.spaces, line.tabs = count_soft_tabs(text)
|
||||||
line = uline.rstrip
|
|
||||||
|
|
||||||
if line.empty?
|
if line.text.empty?
|
||||||
next if @flat_spaces == -1
|
process_indent(old_line.tabs, old_line.text) unless !flat? || old_line.text.empty?
|
||||||
|
next unless flat?
|
||||||
|
|
||||||
process_indent(old_tabs, old_line) unless old_line.empty?
|
push_flat(old_line.text, old_line.spaces)
|
||||||
next if @flat_spaces == -1
|
old_line.text, old_line.unstripped, old_line.spaces = '', '', 0
|
||||||
|
|
||||||
push_flat(old_line, old_spaces)
|
|
||||||
old_line = ''
|
|
||||||
old_uline = ''
|
|
||||||
old_spaces = 0
|
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
suppress_render = handle_multiline(old_tabs, old_line, old_index) if @flat_spaces == -1
|
suppress_render = handle_multiline(old_line.tabs, old_line.text, old_line.index) unless flat?
|
||||||
if old_line && !suppress_render
|
|
||||||
process_indent(old_tabs, old_line) unless old_line.empty?
|
|
||||||
|
|
||||||
if @flat_spaces == -1 && old_spaces != old_tabs * 2
|
if old_line.text.nil? || suppress_render
|
||||||
raise SyntaxError.new("Illegal Indentation: Only two space characters are allowed as tabulation.")
|
old_line = line
|
||||||
end
|
next
|
||||||
|
end
|
||||||
if @flat_spaces != -1
|
|
||||||
push_flat(old_uline, old_spaces)
|
process_indent(old_line.tabs, old_line.text) unless old_line.text.empty?
|
||||||
elsif !old_line.empty? && !@haml_comment
|
|
||||||
process_line(old_line, old_index, tabs > old_tabs && !line.empty?)
|
if flat?
|
||||||
end
|
push_flat(old_line.unstripped, old_line.spaces)
|
||||||
|
old_line = line
|
||||||
if @flat_spaces == -1 && tabs - old_tabs > 1
|
next
|
||||||
raise SyntaxError.new("Illegal Indentation: Indenting more than once per line is illegal.")
|
end
|
||||||
end
|
|
||||||
|
if old_line.spaces != old_line.tabs * 2
|
||||||
|
raise SyntaxError.new("Illegal Indentation: Only two space characters are allowed as tabulation.")
|
||||||
|
end
|
||||||
|
|
||||||
|
unless old_line.text.empty? || @haml_comment
|
||||||
|
process_line(old_line.text, old_line.index, line.tabs > old_line.tabs && !line.text.empty?)
|
||||||
|
end
|
||||||
|
|
||||||
|
if !flat? && line.tabs - old_line.tabs > 1
|
||||||
|
raise SyntaxError.new("Illegal Indentation: Indenting more than once per line is illegal.")
|
||||||
end
|
end
|
||||||
|
|
||||||
old_line = line
|
old_line = line
|
||||||
old_index = index
|
|
||||||
old_spaces = spaces
|
|
||||||
old_tabs = tabs
|
|
||||||
old_uline = uline
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Close all the open tags
|
# Close all the open tags
|
||||||
@template_tabs.times { close }
|
close until @to_close_stack.empty?
|
||||||
flush_merged_text
|
flush_merged_text
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -734,5 +732,9 @@ END
|
||||||
@to_close_stack.push(value)
|
@to_close_stack.push(value)
|
||||||
@template_tabs += 1
|
@template_tabs += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def flat?
|
||||||
|
@flat_spaces != -1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue