-
-
Save brianmcallister/22731529aeaa3ea657bd to your computer and use it in GitHub Desktop.
map-me: A way to extract values from a nested map.
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
// 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