0

I have this project with a bunch of words repeting themselfs.

    &-blue-square {
      @include msc.blue-square;
    }

    &-orange-square {
      @include msc.orange-square;
    }

    &-pink-square {
      @include msc.pink-square;
    }

So i created a loop with @each to improve my code, but the loop doesn't work. Someone knows what can be done in this case?

$colors: (orange, pink, blue);

@each $color in $colors {
  &-#{$color}-square{
    @include msc.#{$color}-square;
  }
}
  • Where are the mixins you're trying to `@include` so we can have a reproducible example? – Chris W. Oct 20 '22 at 17:45
  • This isnt a mixin, its a function. You cant use include in that function because you arnt assigning it to anything – Brad Oct 20 '22 at 22:23
  • @FreitasLucas01 you said **parent** in your question. But put only part of your code that is not includes any parent. Also it is not clear that what is **msc**? Is it a mixin in the same file? or it is a module imported? or anything else? – hamid-davodi Oct 21 '22 at 04:48
  • Does this answer your question? [Creating or referencing variables dynamically in Sass](https://stackoverflow.com/questions/8533432/creating-or-referencing-variables-dynamically-in-sass) – Arkellys Oct 24 '22 at 04:56

0 Answers0