I'm trying to rewrite some SCSS to reduce duplicate code written below...
.bg-primary {
background: $primary;
}
.bg-secondary {
background: $secondary;
}
.bg-tertiary {
background: $tertiary;
}
...to something like this:
$colors: primary secondary tertiary;
@each $color in $colors {
.bg-#{$color}{
background: $color;
}
}
The problem however is that background: $color
will output background: primary;
instead of background: $primary;
which on his turn should be processed as background: #000;
. Any thoughts on how I could make this work? Thanks!