You are here

private function HamlParser::setIndentChar in Sassy 7

* Determine the indent character and indent spaces. * The first character of the first indented line determines the character. * If this is a space the number of spaces determines the indentSpaces; this * is always 1 if the indent character is a tab. *

Throws

HamlException if the indent is mixed

1 call to HamlParser::setIndentChar()
HamlParser::toTree in phamlp/haml/HamlParser.php
* Parse Haml source into a document tree. *

File

phamlp/haml/HamlParser.php, line 562

Class

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

Code

private function setIndentChar() {
  foreach ($this->source as $l => $source) {
    if (!empty($source) && in_array($source[0], $this->indentChars)) {
      $this->indentChar = $source[0];
      for ($i = 0, $len = strlen($source); $i < $len && $source[$i] == $this->indentChar; $i++) {
      }
      if ($i < $len && in_array($source[$i], $this->indentChars)) {
        $this->line = ++$l;
        $this->source = $source;
        throw new HamlException('Mixed indentation not allowed', array(), $this);
      }
      $this->indentSpaces = $this->indentChar == ' ' ? $i : 1;
      return;
    }
  }

  // foreach
  $this->indentChar = ' ';
  $this->indentSpaces = 2;
}