/** * SassImportNode. * * @param object source token * * @return SassImportNode */ public function __construct($token, $parent) { parent::__construct($token, $parent); preg_match(self::MATCH, $token->source, $matches); foreach (SassList::_build_list($matches[self::FILES]) as $file) { $this->files[] = trim($file, '"\'; '); } }
public static function extractArgs($string, $include_null = TRUE, $context) { $args = array(); $arg = ''; $paren = 0; $strpos = 0; $strlen = strlen($string); $list = SassList::_build_list($string, ','); $return = array(); foreach ($list as $k => $value) { if (substr($value, -3, 3) == '...' && preg_match(SassVariableNode::MATCH, substr($value, 0, -3) . ':', $match)) { $list = new SassList($context->getVariable($match[SassVariableNode::NAME])); if (count($list->value) > 1) { $return = array_merge($return, $list->value); continue; } } if (strpos($value, ':') !== false && preg_match(SassVariableNode::MATCH, $value, $match)) { $return[$match[SassVariableNode::NAME]] = $match[SassVariableNode::VALUE]; } else { if (substr($value, 0, 1) == '$' && $include_null) { $return[str_replace('$', '', $value)] = NULL; } elseif ($include_null || $value !== NULL) { $return[] = $value; } } } return $return; }
/** * Resolves selectors. * Interpolates SassScript in selectors and resolves any parent references or * appends the parent selectors. * @param SassContext the context in which this node is parsed * * Change: 7/Dec/11 - change to make selector ordering conform to Ruby compiler. */ public function resolveSelectors($context) { $resolvedSelectors = $normalSelectors = array(); $this->parentSelectors = $this->getParentSelectors($context); foreach ($this->selectors as $key => $selector) { $selector = $this->interpolate($selector, $context); $selectors = SassList::_build_list($selector); foreach ($selectors as $selector) { $selector = trim($selector, ' \'"'); // strip whitespace and quotes, just-in-case. if ($this->hasParentReference($selector)) { $resolvedSelectors = array_merge($resolvedSelectors, $this->resolveParentReferences($selector, $context)); } else { $normalSelectors[] = $selector; } } } // foreach // merge with parent selectors if ($this->parentSelectors) { $return = array(); foreach ($this->parentSelectors as $parent) { foreach ($normalSelectors as $selector) { $spacer = substr($selector, 0, 1) == '[' ? '' : ' '; $return[] = $parent . $spacer . $selector; } } $normalSelectors = $return; } return array_merge($normalSelectors, $resolvedSelectors); }
public static function extractArgs($string, $include_null = TRUE) { $args = array(); $arg = ''; $paren = 0; $strpos = 0; $strlen = strlen($string); $list = SassList::_build_list($string, ','); $return = array(); foreach ($list as $k => $value) { if (strpos($value, ':') !== false && preg_match(SassVariableNode::MATCH, $value, $match)) { $return[$match[SassVariableNode::NAME]] = $match[SassVariableNode::VALUE]; } else { if (substr($value, 0, 1) == '$' && $include_null) { $return[str_replace('$', '', $value)] = NULL; } elseif ($include_null || $value !== NULL) { $return[] = $value; } } } return $return; }