SassDirectiveNode.php in Sassy 7.3
File
phpsass/tree/SassDirectiveNode.php
View source
<?php
class SassDirectiveNode extends SassNode {
const NODE_IDENTIFIER = '@';
const MATCH = '/^(@[\\w-]+)/';
public function __construct($token) {
parent::__construct($token);
}
protected function getDirective() {
return $this->token->source;
preg_match('/^(@[\\w-]+)(?:\\s*(\\w+))*/', $this->token->source, $matches);
array_shift($matches);
$parts = implode(' ', $matches);
return strtolower($parts);
}
public function parse($context) {
$this->token->source = $this->script
->evaluate($this->token->source, $context)->value;
$this->children = $this
->parseChildren($context);
return array(
$this,
);
}
public function render() {
$properties = array();
foreach ($this->children as $child) {
$properties[] = $child
->render();
}
return $this->renderer
->renderDirective($this, $properties);
}
public static function isa($token) {
return $token->source[0] === self::NODE_IDENTIFIER;
}
public static function extractDirective($token) {
preg_match(self::MATCH, $token->source, $matches);
return strtolower($matches[1]);
}
}
Classes
Name |
Description |
SassDirectiveNode |
SassDirectiveNode class.
Represents a CSS directive.
@package PHamlP
@subpackage Sass.tree |