/** * @param object $token source token */ public function __construct($token) { preg_match(self::MATCH, $token->source, $matches); parent::__construct($token); if (empty($matches)) { throw new MixinDefinitionNodeException('Invalid Mixin', $this); } $this->name = $matches[self::NAME]; if (isset($matches[self::ARGUMENTS])) { $this->args = \PHPSass\Script\ScriptFunction::extractArgs($matches[self::ARGUMENTS], TRUE, new Context()); } }
/** * Parse this node. * Set passed arguments and any optional arguments not passed to their * defaults, then render the children of the mixin definition. * * @param Context $pcontext the context in which this node is parsed * @return array the parsed node */ public function parse($pcontext) { $mixin = $pcontext->getMixin($this->name); $context = new Context($pcontext); $context->content = $this->children; $argc = count($this->args); $count = 0; $args = ScriptFunction::extractArgs($this->args, FALSE, $context); list($arguments) = ScriptFunction::fill_parameters($mixin->args, $args, $context, $this); $context->setVariables($arguments); $children = []; foreach ($mixin->children as $child) { $child->parent = $this; $children = array_merge($children, $child->parse($context)); } // $context->merge(); return $children; }