You are here

public function HamlParser::__construct in Sassy 7

* HamlParser constructor. *

Parameters

array options: * @return HamlParser

File

phamlp/haml/HamlParser.php, line 330

Class

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

Code

public function __construct($options = array()) {
  if (isset($options['language'])) {
    Phamlp::$language = $options['language'];
    unset($options['language']);
  }
  foreach ($options as $name => $value) {
    $this->{$name} = $value;
  }

  // foreach
  if ($this->ugly) {
    $this->style = 'compressed';
  }
  $this->format = strtolower($this->format);
  if (is_null($this->doctype) && !array_key_exists($this->format, $this->doctypes)) {
    throw new HamlException('Invalid {what} ({value}). Must be one of "{options}"', array(
      '{what}' => 'format',
      '{value}' => $this->format,
      '{options}' => join(', ', array_keys($this->doctypes)),
    ), $this);
  }
  $this->showSource = $this->debug & HamlParser::DEBUG_SHOW_SOURCE;
  $this->showOutput = $this->debug & HamlParser::DEBUG_SHOW_OUTPUT;
  require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'HamlHelpers.php';
  if (isset($this->helperFile)) {
    require_once $this->helperFile;
    $this->helperClass = basename($this->helperFile, ".php");
    if (!is_subclass_of($this->helperClass, 'HamlHelpers')) {
      throw new HamlException('{what} must extend {base} class', array(
        '{what}' => $this->helperClass,
        '{base}' => 'HamlHelpers',
      ), $this);
    }
  }
}