Created
February 27, 2013 13:10
-
-
Save wagerfield/5047792 to your computer and use it in GitHub Desktop.
Ternary Operators in SASS. I stumbled across this great deck from @nickcooley covering the various features of SASS http://www.slideshare.net/nickcooley/advanced-sasscompass and wanted to create a quick Gist demonstrating the use of ternary operators in SASS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example 1 | |
@function theme($value) | |
@return if($value == "light", #FFFFFF, #000000) | |
background: theme("light") // Outputs #FFFFFF | |
background: theme("dark") // Outputs #000000 | |
background: theme("cats") // Outputs #000000 | |
// Example 2 | |
@function even($value) | |
@return if($value % 2, "I'm odd.", "I'm even.") | |
content: event(0) // Outputs "I'm even." | |
content: event(1) // Outputs "I'm odd." | |
content: event(2) // Outputs "I'm even." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment