You are here

private function HamlParser::getLevel in Sassy 7

* Returns the indent level of the line. *

Parameters

array the line: * @param integer line number * @return integer the indent level of the line * @throws Exception if the indent level is invalid

3 calls to HamlParser::getLevel()
HamlParser::getNextLine in phamlp/haml/HamlParser.php
* Gets the next line. *
HamlParser::hasChild in phamlp/haml/HamlParser.php
* Returns a value indicating if the next line is a child of the parent line *
HamlParser::isChildOf in phamlp/haml/HamlParser.php
* Returns a value indicating if $line is a child of a node. * A blank line is a child of a node. *

File

phamlp/haml/HamlParser.php, line 620

Class

HamlParser
HamlParser class. Parses {@link http://haml-lang.com/ Haml} view files. @package PHamlP @subpackage Haml

Code

private function getLevel($line, $n) {
  if ($line[self::HAML_INDENT] && $this->indentChar === ' ') {
    $indent = strlen($line[self::HAML_INDENT]) / $this->indentSpaces;
  }
  else {
    $indent = strlen($line[self::HAML_INDENT]);
  }
  if (!is_integer($indent) || preg_match("/[^{$this->indentChar}]/", $line[self::HAML_INDENT])) {
    throw new HamlException('Invalid indentation', array(), $this);
  }
  return $indent;
}