You are here

private function HamlParser::parseDirective in Sassy 7

* Parse a directive. * Various options are set according to the directive *

Parameters

array line to parse: * @return null

1 call to HamlParser::parseDirective()
HamlParser::parseLine in phamlp/haml/HamlParser.php
* Parse a line of Haml into a HamlNode for the document tree *

File

phamlp/haml/HamlParser.php, line 1092

Class

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

Code

private function parseDirective($line) {
  preg_match('/(\\w+)(\\+|-)?/', $line[self::HAML_CONTENT], $matches);
  switch ($matches[1]) {
    case 's':
      $this->showSource = $matches[2] == '+' ? true : ($matches[2] == '-' ? false : $this->showSource);
      break;
    case 'o':
      $this->showOutput = $matches[2] == '+' ? true : ($matches[2] == '-' ? false : $this->showOutput);
      break;
    case 'os':
    case 'so':
      $this->showSource = $matches[2] == '+' ? true : ($matches[2] == '-' ? false : $this->showSource);
      $this->showOutput = $matches[2] == '+' ? true : ($matches[2] == '-' ? false : $this->showOutput);
      break;
    default:
      if (!in_array($matches[1], $this->styles)) {
        throw new HamlException('Invalid {what} ({value})', array(
          '{what}' => 'directive',
          '{value}' => self::DIRECTIVE . $matches[0],
        ), $this);
      }
      $this->style = $matches[1];
      break;
  }

  // switch
}