Skip to content

Instantly share code, notes, and snippets.

@brianmcallister
Forked from jackie/gist:a65bb078c8c9eb4bbb57
Created July 24, 2014 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianmcallister/22731529aeaa3ea657bd to your computer and use it in GitHub Desktop.
Save brianmcallister/22731529aeaa3ea657bd to your computer and use it in GitHub Desktop.
map-me: A way to extract values from a nested map.
// Extract values from a nested map.
// Original: https://gist.github.com/jackie/a65bb078c8c9eb4bbb57
//
// $map - Map from which to extract the value.
// $keys - List of keys.
//
// Examples
//
// $map: (one: (two: val: 'value'));
// map-me($map, one two val);
// #=> 'value'
//
// Returns the requested value.
@function map-me($map, $keys) {
@each $key in $keys {
@if map-has-key($map, $key) {
$map: map-get($map, $key);
}
}
@return $map;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment