class Haml::Parser::Line

@private

Public Instance Methods

tabs() click to toggle source

@private

# File lib/haml/parser.rb, line 86
      def tabs
        line = self
        @tabs ||= compiler.instance_eval do
          break 0 if line.text.empty? || !(whitespace = line.full[%r^\s+/])

          if @indentation.nil?
            @indentation = whitespace

            if @indentation.include?(\s\) && @indentation.include?(\t\)
              raise SyntaxError.new("Indentation can't use both tabs and spaces.", line.index)
            end

            @flat_spaces = @indentation * (@template_tabs+1) if flat?
            break 1
          end

          tabs = whitespace.length / @indentation.length
          break tabs if whitespace == @indentation * tabs
          break @template_tabs + 1 if flat? && whitespace =~ %r^#{@flat_spaces}/

          raise SyntaxError.new("Inconsistent indentation: #{Haml::Shared.human_indentation whitespace, true} used for indentation,
but the rest of the document was indented using #{Haml::Shared.human_indentation @indentation}.
".strip.gsub("\n", ' '), line.index)
        end
      end