151: def tabs
152: line = self
153: @tabs ||= precompiler.instance_eval do
154: break 0 if line.text.empty? || !(whitespace = line.full[/^\s+/])
155:
156: if @indentation.nil?
157: @indentation = whitespace
158:
159: if @indentation.include?(?\s) && @indentation.include?(?\t)
160: raise SyntaxError.new("Indentation can't use both tabs and spaces.", line.index)
161: end
162:
163: @flat_spaces = @indentation * @template_tabs if flat?
164: break 1
165: end
166:
167: tabs = whitespace.length / @indentation.length
168: break tabs if whitespace == @indentation * tabs
169: break @template_tabs if flat? && whitespace =~ /^#{@indentation * @template_tabs}/
170:
171: raise SyntaxError.new("Inconsistent indentation: \#{Haml::Shared.human_indentation whitespace, true} used for indentation,\nbut the rest of the document was indented using \#{Haml::Shared.human_indentation @indentation}.\n".strip.gsub("\n", ' '), line.index)
172: end
173: end