Skip to content

Instantly share code, notes, and snippets.

@mattdrose
Created June 19, 2015 17:37
Show Gist options
  • Save mattdrose/3656183f335d34b80ed1 to your computer and use it in GitHub Desktop.
Save mattdrose/3656183f335d34b80ed1 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.14)
// Compass (v1.0.3)
// ----
/*
type-of(100px) => #{type-of(100px)}
type-of(asdf) => #{type-of(asdf)}
type-of(true) => #{type-of(true)}
type-of(#fff) => #{type-of(#fff)}
type-of(blue) => #{type-of(blue)}
*/
$gemini-base: (
100px: true,
asdf: true,
true: true,
#fff: true,
blue: true,
layer1: (
layer2: true
)
);
@function get($key, $map: $gemini-base) {
@if type-of($key) == string and (str-index($key, ".") or 0) > 0 {
$parent-key: str-slice($key, 1, str-index($key, ".") - 1);
$child-key: str-slice($key, str-index($key, ".") + 1);
@if type-of(map-get($map, $parent-key)) == map {
@return get($child-key, map-get($map, $parent-key));
}
}
@return map-get($map, $key);
}
/*
#{get(100px)}
#{get(asdf)}
#{get(true)}
#{get(#fff)}
#{get(blue)}
#{get("layer1.layer2")}
*/
/*
type-of(100px) => number
type-of(asdf) => string
type-of(true) => bool
type-of(#fff) => color
type-of(blue) => color
*/
/*
true
true
true
true
true
true
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment