Last active
August 29, 2015 13:56
-
-
Save pixelass/8835048 to your computer and use it in GitHub Desktop.
compare to lists to find matches
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
@import 'for'; | |
// compare two lists | |
// the wild animals will show a picture and a warning "This animal is wild" | |
// others do not | |
@wild: bear, tiger, elefant, lion, zebra, crocodile, gorilla; | |
@animals: gorilla, dog, cat, hamster, tiger; | |
.in(@array, @value) { | |
.for(@array); .-each(...) {} | |
.-each(~'@{value}') {@-: true} | |
.-() {@-: false} .-; | |
} | |
.wild(@bool) when (@bool) { | |
&:before { | |
content: url('../images/@{i}.png'); | |
} | |
&:after { | |
content: 'This animal is wild.' | |
} | |
} | |
.animal { | |
.for(@animals);.-each(@i){ | |
.in(@wild, @i); | |
&.@{i} { | |
.wild(@-); | |
} | |
} | |
} | |
// output | |
//.animal.gorilla:before { | |
// content: url('../images/gorilla.png'); | |
//} | |
//.animal.gorilla:after { | |
// content: 'This animal is wild.'; | |
//} | |
//.animal.tiger:before { | |
// content: url('../images/tiger.png'); | |
//} | |
//.animal.tiger:after { | |
// content: 'This animal is wild.'; | |
//} | |
// example: http://codepen.io/pixelass/pen/Ggkwy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment