| Class | Haml::Precompiler::Line |
| In: |
lib/haml/precompiler.rb
|
| Parent: | Struct.new(:text, :unstripped, :full, :index, :precompiler, :eod) |
@private
| eod | -> | eod? |
@private
# File lib/haml/precompiler.rb, line 152
152: def tabs
153: line = self
154: @tabs ||= precompiler.instance_eval do
155: break 0 if line.text.empty? || !(whitespace = line.full[/^\s+/])
156:
157: if @indentation.nil?
158: @indentation = whitespace
159:
160: if @indentation.include?(?\s) && @indentation.include?(?\t)
161: raise SyntaxError.new("Indentation can't use both tabs and spaces.", line.index)
162: end
163:
164: @flat_spaces = @indentation * @template_tabs if flat?
165: break 1
166: end
167:
168: tabs = whitespace.length / @indentation.length
169: break tabs if whitespace == @indentation * tabs
170: break @template_tabs if flat? && whitespace =~ /^#{@indentation * @template_tabs}/
171:
172: 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)
173: end
174: end