You are here

public function SassForNode::parse in Sassy 7.3

Same name and namespace in other branches
  1. 7 phamlp/sass/tree/SassForNode.php \SassForNode::parse()

Parse this node.

Parameters

SassContext the context in which this node is parsed:

Return value

array parsed child nodes

File

phpsass/tree/SassForNode.php, line 82

Class

SassForNode
SassForNode class. Represents a Sass @for loop. @package PHamlP @subpackage Sass.tree

Code

public function parse($context) {
  $children = array();
  $from = (double) $this
    ->evaluate($this->from, $context)->value;
  $to = (double) $this
    ->evaluate($this->to, $context)->value;
  $step = (double) $this
    ->evaluate($this->step, $context)->value * ($to > $from ? 1 : -1);
  if ($this->inclusive) {
    $to += $from < $to ? 1 : -1;
  }
  $context = new SassContext($context);
  for ($i = $from; $from < $to ? $i < $to : $i > $to; $i = $i + $step) {
    $context
      ->setVariable($this->variable, new SassNumber($i));
    $children = array_merge($children, $this
      ->parseChildren($context));
  }
  return $children;
}