private function SassRuleNode::explode in Sassy 7.3
Same name and namespace in other branches
- 7 phamlp/sass/tree/SassRuleNode.php \SassRuleNode::explode()
Explodes a string of selectors into an array. We can't use PHP::explode as this will potentially explode attribute matches in the selector, e.g. div[title="some,value"] and interpolations.
Parameters
string selectors:
Return value
array selectors
1 call to SassRuleNode::explode()
- SassRuleNode::addSelectors in phpsass/
tree/ SassRuleNode.php - Adds selector(s) to the rule. If the selectors are to continue for the rule the selector must end in a comma
File
- phpsass/
tree/ SassRuleNode.php, line 311
Class
- SassRuleNode
- SassRuleNode class. Represents a CSS rule. @package PHamlP @subpackage Sass.tree
Code
private function explode($string) {
$selectors = array();
$inString = false;
$interpolate = false;
$selector = '';
for ($i = 0, $l = strlen($string); $i < $l; $i++) {
$c = $string[$i];
if ($c === self::CONTINUED && !$inString && !$interpolate) {
$selectors[] = trim($selector);
$selector = '';
}
else {
$selector .= $c;
if ($c === '"' || $c === "'") {
do {
$_c = $string[++$i];
$selector .= $_c;
} while ($_c !== $c);
}
elseif ($c === '#' && $string[$i + 1] === '{') {
do {
$c = $string[++$i];
$selector .= $c;
} while ($c !== '}');
}
}
}
if (!empty($selector)) {
$selectors[] = trim($selector);
}
return $selectors;
}