Skip to content

Instantly share code, notes, and snippets.

@lunelson
Created October 21, 2013 09:18
Show Gist options
  • Save lunelson/7080971 to your computer and use it in GitHub Desktop.
Save lunelson/7080971 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// 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);
}
}
.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