Reputation: 2002
I am using SASS to construct a range of classes from variables passed into a mixin.
@mixin classes($key, $num) {
@for $i from 1 through $num {
[class*=#{$key}-#{$i}] {
@content
}
}
}
@include classes(grid, 8) {
width:100px;
}
It currently makes the classes like I want, but all as 8 separate classes (which are identical in @contents. Is there a way to merge them all together so I get:
[class*=grid-1],
[class*=grid-2],
....
[class*=grid-8],
{
width:100px;
}
I'm not sure if it's even possible to do this? Any pointers would be greatly appreciated.
Thanks,
Carl
Upvotes: 3
Views: 967
Reputation: 2002
$classes: ();
@for $i from 1 through $cols {
$classes: join($classes, unquote("#{$prefix}#{$i} "), comma);
}
#{$classes} {
float: left;
margin-right: $gutterPercent;
width: $columnWidth;
}
Upvotes: 5