sasslessscss-mixinsscss-lintlesscss-resources

SCSS Passing numeric value in Interpolation


this is not working, Help needed, am I missing some thing??

I am trying to achieve Variable numeric value for @for $i ..... through .... {... , passing from mixin

$colors: ('primary': #000, 'secondary': #fff);

@mixin titleTxt($title, $start, $end) {
  @for $i from #{$start} through #{$end} {
    @if $i % 2==0 {
      .#{$title}-#{$i} {
        color: #000;

        @each $name,
        $color in $colors {
          &-#{$name} {
            color: #{$color};
          }
        }
      }
    }
  }
}

@include titleTxt("text", 16, 24)


Solution

  • The line @for $i from #{$start} through #{$end} is performing string interpolation for the start and end args, which cause the 'not a number' error.

    Removin the #{...} string interpolation syntax and simply going with @for $i from $start through $end should solve your issue