I want to assign several @mixins to classes with the same name, something like:
@each $herramienta in $listaHerramientas {
.#{$herramienta} {
@include #{$herramienta};
}
}
The compiler throws the error Expected identifier
, which seems to mean the @include does not admit variables. Is that right? Is there a way to avoid writing all classes one by one?
2
Answers
Yes, you’re correct that SCSS does not allow variables to be used directly as mixin names in the
@include
directive. However, there is a way to achieve this by using the@if
or@else if
conditions to include the appropriate mixin based on the value of the variable.