SassWhileNode.php in Sassy 7.3
File
phpsass/tree/SassWhileNode.php
View source
<?php
class SassWhileNode extends SassNode {
const MATCH = '/^@(do|while)\\s+(.+)$/i';
const LOOP = 1;
const EXPRESSION = 2;
const IS_DO = 'do';
private $isDo;
private $expression;
public function __construct($token) {
parent::__construct($token);
preg_match(self::MATCH, $token->source, $matches);
$this->expression = $matches[self::EXPRESSION];
$this->isDo = $matches[self::LOOP] === SassWhileNode::IS_DO;
}
public function parse($context) {
$children = array();
if ($this->isDo) {
do {
$children = array_merge($children, $this
->parseChildren($context));
} while ($this
->evaluate($this->expression, $context)
->toBoolean());
}
else {
while ($this
->evaluate($this->expression, $context)
->toBoolean()) {
$children = array_merge($children, $this
->parseChildren($context));
}
}
return $children;
}
}
Classes
Name |
Description |
SassWhileNode |
SassWhileNode class.
Represents a Sass @while loop and a Sass @do loop.
@package PHamlP
@subpackage Sass.tree |