118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/haml/precompiler.rb', line 118
def tabs
line = self
@tabs ||= precompiler.instance_eval do
break 0 if line.text.empty? || !(whitespace = line.full[/^\s+/])
if @indentation.nil?
@indentation = whitespace
if @indentation.include?(?\s) && @indentation.include?(?\t)
raise SyntaxError.new("Indentation can't use both tabs and spaces.", line.index)
end
@flat_spaces = @indentation * @template_tabs if flat?
break 1
end
tabs = whitespace.length / @indentation.length
break tabs if whitespace == @indentation * tabs
break @template_tabs if flat? && whitespace =~ /^#{@indentation * @template_tabs}/
raise SyntaxError.new(<<END.strip.gsub("\n", ' '), line.index)
Inconsistent indentation: #{Haml::Shared.human_indentation whitespace, true} used for indentation,
but the rest of the document was indented using #{Haml::Shared.human_indentation @indentation}.
END
end
end
|