Skip to content

Instantly share code, notes, and snippets.

@mattdrose
Last active August 29, 2015 14:07
Show Gist options
  • Save mattdrose/588c5a59ba973e3fca43 to your computer and use it in GitHub Desktop.
Save mattdrose/588c5a59ba973e3fca43 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.5)
// Compass (v1.0.1)
// ----
@function get($key, $map: null) {
@if $map == null {
$map: $default-settings;
}
$break: false;
@while (str-index($key, ".") or 0) > 0 and $break == false {
$child-key: str-slice($key, 1, str-index($key, ".") - 1);
$key: str-slice($key, str-index($key, ".") + 1);
@if type-of(map-get($map, $child-key)) == map {
$map: map-get($map, $child-key);
} @else {
$break: true;
}
}
@return if(type-of($map) == map, map-get($map, $key), $map);
}
$default-settings: (
fonts: (
primary: (
size: 1.2em,
color: blue,
family: "Helvetica",
),
secondary: (
size: 1em,
color: green,
family: sans-serif,
)
)
);
.primary-font {
font-family: get("fonts.primary.family");
font-size: get("fonts.primary.size");
color: get("fonts.primary.color");
}
.primary-font {
font-family: "Helvetica";
font-size: 1.2em;
color: blue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment