You are here

public function SassMixinNode::parse in Sassy 7.3

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

Parse this node. Set passed arguments and any optional arguments not passed to their defaults, then render the children of the mixin definition.

Parameters

SassContext the context in which this node is parsed:

Return value

array the parsed node

File

phpsass/tree/SassMixinNode.php, line 59

Class

SassMixinNode
SassMixinNode class. Represents a Mixin. @package PHamlP @subpackage Sass.tree

Code

public function parse($pcontext) {
  $mixin = $pcontext
    ->getMixin($this->name);
  $context = new SassContext($pcontext);
  $argc = count($this->args);
  $count = 0;
  foreach ($mixin->args as $name => $value) {
    if ($count < $argc) {
      $context
        ->setVariable($name, $this
        ->evaluate($this->args[$count++], $context));
    }
    elseif (!is_null($value)) {
      $context
        ->setVariable($name, $this
        ->evaluate($value, $context));
    }
    else {
      print_r($this->name);
      print_r($mixin->token);
      throw new SassMixinNodeException("Mixin::{$name}: Required variable ({$this->name}) not given.\nMixin defined: ' . {$mixin->token}->filename . '::' . {$mixin->token}->line . '\nMixin used", $this);
    }
  }

  // foreach
  $children = array();
  foreach ($mixin->children as $child) {
    $child->parent = $this;
    $children = array_merge($children, $child
      ->parse($context));
  }

  // foreach

  //$context->merge();
  return $children;
}