function sassy_compass__list in Sassy 7.2
Same name and namespace in other branches
- 7.3 sassy_compass/functions/lists.inc \sassy_compass__list()
9 calls to sassy_compass__list()
- sassy_compass__is_position_list in extensions/
compass/ functions/ constants.inc - sassy_compass__opposite_position in extensions/
compass/ functions/ constants.inc - sassy_compass__prefix in extensions/
compass/ functions/ cross_browser_support.inc - sassy_compass__prefixed in extensions/
compass/ functions/ cross_browser_support.inc - sassy_compass___compass_list in extensions/
compass/ functions/ lists.inc
File
- extensions/
compass/ functions/ lists.inc, line 98
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 = implode(', ', $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;
}