Skip to content

Instantly share code, notes, and snippets.

@mnelson
Created May 15, 2014 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnelson/f1045e03b91ab1d71ed6 to your computer and use it in GitHub Desktop.
Save mnelson/f1045e03b91ab1d71ed6 to your computer and use it in GitHub Desktop.
Tenant mixin for sass variables.
/*
$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