| 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 134
134: def tabs
135: line = self
136: @tabs ||= precompiler.instance_eval do
137: break 0 if line.text.empty? || !(whitespace = line.full[/^\s+/])
138:
139: if @indentation.nil?
140: @indentation = whitespace
141:
142: if @indentation.include?(?\s) && @indentation.include?(?\t)
143: raise SyntaxError.new("Indentation can't use both tabs and spaces.", line.index)
144: end
145:
146: @flat_spaces = @indentation * @template_tabs if flat?
147: break 1
148: end
149:
150: tabs = whitespace.length / @indentation.length
151: break tabs if whitespace == @indentation * tabs
152: break @template_tabs if flat? && whitespace =~ /^#{@indentation * @template_tabs}/
153:
154: 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)
155: end
156: end