Skip to content

Instantly share code, notes, and snippets.

@MoOx
Created December 12, 2012 08:54
Show Gist options
  • Save MoOx/4266210 to your computer and use it in GitHub Desktop.
Save MoOx/4266210 to your computer and use it in GitHub Desktop.
Is there a sort of ternary operator in #Sass ?
//...
$background: null; // if you don't do this, background is undefined out of the @if/else scope
@if ($direction) {
$background: linear-gradient($direction, $color, $color2);
}
@else {
$background: linear-gradient($color, $color2);
}
//...
// can we do something like this ?
$background: $direction ? /* value */ : /* other value */;
@chriseppstein
Copy link

In sass 3.3, the if function only evaluates the argument that corresponds to the condition. This makes the if function as powerful as the @if directive.

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