Class Haml::Precompiler::Line
In: lib/haml/precompiler.rb
Parent: Struct.new(:text, :unstripped, :full, :index, :precompiler, :eod)

Methods

tabs  

External Aliases

eod -> eod?

Public Instance methods

[Source]

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

[Validate]