Skip to content

Instantly share code, notes, and snippets.

@JulienCabanes
Created January 27, 2014 20:35
Show Gist options
  • Save JulienCabanes/8656771 to your computer and use it in GitHub Desktop.
Save JulienCabanes/8656771 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.2)
// Compass (v1.0.0.alpha.17)
// SassyCast (v0.0.1)
// ----
@import "SassyCast";
@function to-list($value, $keep: 'both') {
@if type-of($value) == map {
$keys: ();
$values: ();
@each $key, $val in $value {
$keys: append($keys, $key);
$values: append($values, $val);
}
@if $keep == 'both' {
@return zip($keys, $values);
} @else {
@return if($keep == 'keys', $keys, $values);
}
}
@return if(type-of($value) != list, ($value,), $value);
}
$list: lorem ipsum;
$map: to-map($list);
div {
foo: to-list($map);
bar: to-list($map, 'keys');
baz: to-list($map, 'values');
}
div {
foo: 1 lorem, 2 ipsum;
bar: 1 2;
baz: lorem ipsum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment