Created
May 15, 2014 19:18
-
-
Save mnelson/f1045e03b91ab1d71ed6 to your computer and use it in GitHub Desktop.
Tenant mixin for sass variables.
This file contains 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
/* | |
$listvar: | |
"appname1" "blue", | |
"appname2" "red" | |
; | |
.my-selector { | |
@include tenant($listvar) { | |
background-color: $var; | |
} | |
} | |
*/ | |
$var: null; | |
@mixin tenant($variable) { | |
@if length($variable) > 1 { | |
@each $pair in $variable { | |
@if length($pair) > 1 { | |
$tenant: nth($pair, 1); | |
$var: nth($pair, 2); | |
.ten-#{$tenant} & { | |
@content; | |
} | |
} @else { | |
$var: $pair; | |
@content; | |
} | |
} | |
} @else { | |
$var: $variable; | |
@content; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment