I have the following mixen, inside of it i’m trying to loop based on arguments.
@mixin detCls($s, $e) {
@for $i from #{$s} through #{$e} {
// doing some stuffs
}
}
@include detCls(16, 24)
But while complying it throws an error
@for $i from #{$s} through #{$e} { 16 is not a number.
user27276754 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
You don’t need string interpolation #{...}
, just use $s
, $e
.
@mixin detCls($s, $e) {
@for $i from $s through $e {
// doing some stuffs
}
}
@include detCls(16, 24)
Interpolation with #{}
is used for converting variables into strings, but in this case, you need the numeric values directly for the loop.
@mixin detCls($s, $e) {
@for $i from $s through $e {
// doing some stuff
}
}
@include detCls(16, 24);
Rob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
I think you should guard input first by adding condition @if $s > $e
then modify your forloop with this @for $i from $s through $e