Created
October 21, 2013 09:18
-
-
Save lunelson/7080971 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.1) | |
// Compass (v0.13.alpha.7) | |
// ---- | |
// a compound map value retrieval function, arbitrary level of depth | |
@function map-value($map, $keys...) { | |
@each $key in $keys { $map: map-get($map, $key); } | |
@return $map; | |
} | |
// a map output mixin, iterates at arbitrary level of depth | |
@mixin map-iterate($map, $keys...) { | |
@each $key, $value in map-value($map, $keys...) { | |
#{$key}: $value; | |
} | |
} | |
// sample nested map | |
$font-data: ( | |
body: ( | |
font-family: (georgia, serif), | |
font-style: normal, | |
font-weight: normal | |
), | |
heading: ( | |
font-family: (helvetica, sans-serif), | |
font-style: normal, | |
font-weight: bold | |
) | |
); | |
// test output | |
.test { | |
single-value: map-value($font-data, body, font-family); | |
.iteration { | |
@include map-iterate($font-data, heading); | |
} | |
} |
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
.test { | |
single-value: georgia, serif; | |
} | |
.test .iteration { | |
font-family: helvetica, sans-serif; | |
font-style: normal; | |
font-weight: bold; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment