less2sass icon indicating copy to clipboard operation
less2sass copied to clipboard

Could not converted the conditional statements

Open anujaykumar1 opened this issue 9 years ago • 5 comments

i am trying less2sass for converting my legacy less version to scss, i would like to know what is "when" in less is it the "if" statement ?

i was expecting proper output for .biggerX (@index) when (@index < 310) { .bigger-@{index} { font-size: unit(@index,~"%"); } .biggerX(@index + 10); }

but i found

@mixin biggerX($index) when ($index < 310) { .bigger-${index} { font-size: unit($index,#{"%"}); } @include biggerX($index + 10); }

if when (in less)== if (in scss) then it suppose to make this conversion as well. Do suggest me how may i proceed.

anujaykumar1 avatar Mar 16 '16 14:03 anujaykumar1

@amoebageek Yes when is synonymous with if in SCSS but the syntax is pretty different. Like I said in the README this isn't perfect so you'll need to convert some things over manually. If you want to make an attempt at a PR I'll gladly take it but I don't really have a need for this script anymore so implementing the fix myself is pretty low priority for me.

ekryski avatar Mar 19 '16 02:03 ekryski

This is actually a duplicate of #6 actually. We'll keep this one open for more context.

ekryski avatar Mar 19 '16 02:03 ekryski

I had the same problem. Just pasting the problematic code for reference:

.make-nested-list(@offset, @i, @n) when (@i < @n) {
  > .dropdown-menu > li {
    &.dropdown-header,
    > a {
      padding-left: @offset + (10 * @i);
    }

    .make-nested-list(@offset, @i + 1, @n);
  }
}

gagarine avatar Jun 23 '17 15:06 gagarine

@gagarine Can you also add the expected output in Scss?

Maybe we can deal with the simpler cases for this one.

MonsieurV avatar Jun 23 '17 16:06 MonsieurV

Sure. I believe (not full tested yet, but it compile) it should be:

@mixin make-nested-list($offset, $i, $n) {
  @if ($i < $n) {
    > .dropdown-menu > li {
      &.dropdown-header,
      > a {
        padding-left: $offset + (10 * $i);
      }

      @include make-nested-list($offset, $i + 1, $n);
    }
  }
}

gagarine avatar Jun 23 '17 17:06 gagarine