123: def tabs
124: line = self
125: @tabs ||= precompiler.instance_eval do
126: break 0 if line.text.empty? || !(whitespace = line.full[/^\s+/])
127:
128: if @indentation.nil?
129: @indentation = whitespace
130:
131: if @indentation.include?(?\s) && @indentation.include?(?\t)
132: raise SyntaxError.new("Indentation can't use both tabs and spaces.", line.index)
133: end
134:
135: @flat_spaces = @indentation * @template_tabs if flat?
136: break 1
137: end
138:
139: tabs = whitespace.length / @indentation.length
140: break tabs if whitespace == @indentation * tabs
141: break @template_tabs if flat? && whitespace =~ /^#{@indentation * @template_tabs}/
142:
143: 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)
144: end
145: end