Created
January 27, 2014 20:35
-
-
Save JulienCabanes/8656771 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// 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'); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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