Skip to content

Instantly share code, notes, and snippets.

@nex3
Created May 12, 2015 22:50
Show Gist options
  • Save nex3/598197bcd8a4ce2e711e to your computer and use it in GitHub Desktop.
Save nex3/598197bcd8a4ce2e711e to your computer and use it in GitHub Desktop.
@function safe($name, $args...) {
@each $arg in join($args, map-values(keywords($args))) {
@if $arg == null {
@return null;
}
}
@return call($name, $args...);
}
@kaelig
Copy link

kaelig commented May 12, 2015

For reference, the second line is here so that all of these use cases work as expected:

el {
  color: safe(mix, $color1: grey, $color2: null, $weight: 12%);
  color: safe(mix, $color1: grey, $color2: red, $weight: 12%);
  color: safe(mix, grey, null, 12%);
  color: safe(mix, grey, red, 12%);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment