Parent

Methods

Haml::Parser::Line

@private

Public Instance Methods

tabs() click to toggle source

@private

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

    if @indentation.nil?
      @indentation = whitespace

      if @indentation.include?(\s\) && @indentation.include?(\t\)
        raise SyntaxError.new(Error.message(:cant_use_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 =~ /^#{@flat_spaces}/

    message = Error.message(:inconsistent_indentation,
      Haml::Util.human_indentation(whitespace),
      Haml::Util.human_indentation(@indentation)
    )
    raise SyntaxError.new(message, line.index)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.