/** * Parse this node. * This raises an error. * @return array An empty array */ public function parse($context) { // If we are in a loop, function or mixin then the parent isn't what should // go inside the media node. Walk up the parent tree to find the rule node // to put inside the media node or the root node if the media node should be // at the root. $parent = $this->parent; while (!$parent instanceof SassRuleNode && !$parent instanceof SassRootNode) { $parent = $parent->parent; } // Make a copy of the token before parsing in case we are in a loop and it contains variables $token = clone $this->token; $token->source = SassDirectiveNode::interpolate_nonstrict($token->source, $context); $node = new SassRuleNode($token, $context); $node->root = $parent->root; $rule = clone $parent; $rule->root = $node->root; $rule->children = $this->children; $try = $rule->parse($context); if (is_array($try)) { $rule->children = $try; } // Tests were failing with this, but I'm not sure if we cover every case. //else if (is_object($try) && method_exists($try, 'render')) { // $rule = $try; //} $node->children = array(new SassString($rule->render($context))); return array($node); }
/** * Parse this node. * This raises an error. * @return array An empty array */ public function parse($context) { $this->token->source = SassDirectiveNode::interpolate_nonstrict($this->token->source, $context); $node = new SassRuleNode($this->token, $context); $node->root = $this->parent->root; $rule = clone $this->parent; $rule->root = $node->root; $rule->children = $this->children; $try = $rule->parse($context); if (is_array($try)) { $rule->children = $try; } // Tests were failing with this, but I'm not sure if we cover every case. //else if (is_object($try) && method_exists($try, 'render')) { // $rule = $try; //} $node->children = array(new SassString($rule->render($context))); return array($node); }