示例#1
0
 /**
  * @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());
     }
 }
示例#2
0
 /**
  * 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;
 }
示例#3
0
 /**
  * Evalutes the function in the given context, with the provided arguments
  *
  * @param Context $pcontext - the parent context
  * @param array $provided - the list of provided variables
  * @throws SassReturn - if the @return is fired then this is thrown to break early
  * @return \PHPSass\Script\Literals\Boolean (false) - if no @return was fired, return false
  */
 public function execute($pcontext, $provided)
 {
     list($arguments, $context) = \PHPSass\Script\ScriptFunction::fill_parameters($this->args, $provided, $pcontext, $this);
     $context->setVariables($arguments);
     $children = [];
     try {
         foreach ($this->children as $child) {
             $child->parent = $this;
             $children = array_merge($children, $child->parse($context));
         }
     } catch (SassReturn $e) {
         return $e->value;
     }
     return new \PHPSass\Script\Literals\Boolean(FALSE);
 }