Skip to content

Instantly share code, notes, and snippets.

@mturjak
Created February 17, 2014 00:25
Show Gist options
  • Save mturjak/9042651 to your computer and use it in GitHub Desktop.
Save mturjak/9042651 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.4)
// Compass (v1.0.0.alpha.18)
// ----
//recursive map-has-key() function
@function rmhk($m, $a){
@if type-of($m) == map {
@if map-has-key($m, $a) { @return true; };
@each $key,$e in $m {
@if rmhk($e, $a) { @return true; }
}
}
@return false;
}
$map: (
config: (
foo: (
a: 1,
b: 2,
),
bar: (
a: 3,
b: 4,
),
));
test {
test1: type-of($map);
test2: map-has-key($map, bar);
test3: rmhk($map, bar);
}
test {
test1: map;
test2: false;
test3: true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment