Sha256: c1ddd7900965d4f8d191ab8e09ed6e94168dfc12813f82424aa0c6cb88bc80dd

Contents?: true

Size: 836 Bytes

Versions: 5

Compression:

Stored size: 836 Bytes

Contents

// Fetch value from key in map
// -------------------------------------------------------------------------------
// @param $map [map] : map to fetch from
// @param $keys [string | list] : string of key, or list of strings
// -------------------------------------------------------------------------------
// @return fetched literal | false

@function flint-map-fetch($map, $keys) {
	$key: nth($keys, 1);
	$length: length($keys);
	$value: map-get($map, $key);

	@if $value != null {
		@if $length > 1 {
			$rest: ();

			@for $i from 2 through $length {
				$rest: append($rest, nth($keys, $i))
			}

			@return flint-map-fetch($value, $rest);

		} @else {
			@return $value;
		}
	} @else {
		@warn "Invalid arguments passed to function: flint-map-fetch(#{$map}, #{$keys}). One or more of the keys do not exist.";
		@return false;
	}
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
flint-gs-1.10.0 stylesheets/flint/functions/lib/_map-fetch.scss
flint-gs-1.9.1 stylesheets/flint/functions/lib/_map-fetch.scss
flint-gs-1.8.0 stylesheets/flint/functions/lib/_map-fetch.scss
flint-gs-1.7.2 stylesheets/flint/functions/lib/_map-fetch.scss
flint-gs-1.7.0 stylesheets/flint/functions/lib/_map-fetch.scss