function sassy_compass__list in Sassy 7.3
Same name and namespace in other branches
- 7.2 extensions/compass/functions/lists.inc \sassy_compass__list()
9 calls to sassy_compass__list()
- sassy_compass__is_position_list in sassy_compass/
functions/ constants.inc - sassy_compass__opposite_position in sassy_compass/
functions/ constants.inc - sassy_compass__prefix in sassy_compass/
functions/ cross_browser_support.inc - sassy_compass__prefixed in sassy_compass/
functions/ cross_browser_support.inc - sassy_compass___compass_list in sassy_compass/
functions/ lists.inc
File
- sassy_compass/
functions/ lists.inc, line 97
Code
function sassy_compass__list($list, $seperator = ',') {
if (is_object($list)) {
$list = $list->value;
}
if (is_array($list)) {
$newlist = array();
foreach ($list as $listlet) {
$newlist = array_merge($newlist, sassy_compass__list($listlet, $seperator));
}
$list = $newlist;
}
$out = array();
$size = 0;
$braces = 0;
$stack = '';
for ($i = 0; $i < strlen($list); $i++) {
$char = substr($list, $i, 1);
switch ($char) {
case '(':
$braces++;
$stack .= $char;
break;
case ')':
$braces--;
$stack .= $char;
break;
case $seperator:
if ($braces === 0) {
$out[] = $stack;
$stack = '';
$size++;
break;
}
default:
$stack .= $char;
}
}
$out[] = $stack;
return $out;
}