Reputation: 59
I'm trying to create an each loop that creates a class name and calls a mixin with that name as the parameter. The idea is that I can make a list:
$list: (item1, item2, item3, ect);
Then run an each loop to create a class using that name and call a mixin with that name as the parameter.
@each $name in $list {
.#{$name} {
@include mixin($name);
}
}
That parameter in the mixin calls another variable of the same name to set the attributes I need within the mixin. This seems like something I should be able to do but can't seem to figure out how to make the mixin parameter as a variable instead of just a string of text. Do I have to use interpolation in a specific way to be able to add the $ in front of the list name? Doing this doesn't seem to work:
@include mixin($#{$name});
What I need it to do is use the values of item1, item2, item3, ect to create the class name but then send them as variables $item1, $item2, $item3 through the mixin and I'm not sure what else to try.
Upvotes: 0
Views: 2709
Reputation: 333
Using just the variable name $name
as you did the first time will work.
Here is an example I made using your code.
Upvotes: 1