ekryski / less2sass

A little script to convert less to sass files
MIT License
273 stars 40 forks source link

Mixin and Include conversions should handle parameters on multiple lines #3

Closed bitfyre closed 8 years ago

bitfyre commented 9 years ago

Rework regex patterns for mixins and includes with parameters that span multiple lines. The following mixin:

.drop-shadow(
  @x-axis: 0,
  @y-axis: 1px,
  @blur: 2px,
  @alpha: 0.1
) {
  -webkit-box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
  -moz-box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
  box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
}

should convert to:

@mixin drop-shadow(
  $x-axis: 0,
  $y-axis: 1px,
  $blur: 2px,
  $alpha: 0.1
) {
  -webkit-box-shadow: $x-axis $y-axis $blur rgba(0, 0, 0, $alpha);
  -moz-box-shadow: $x-axis $y-axis $blur rgba(0, 0, 0, $alpha);
  box-shadow: $x-axis $y-axis $blur rgba(0, 0, 0, $alpha);
}

The following include:

  .drop-shadow(
    0,
    2px,
    4px,
    0.4
  );

should convert to:

  @include drop-shadow(
    0,
    2px,
    4px,
    0.4
  );

The conversion should also respect the original's level of indentation. This conversion will also convert name spaced mixins like the following:

#grid {
  .column(…) {…};
}

to:

#grid {
  @mixin column(…) {…};
}

This won't compile with any of the existing sass compliers, but is much closer than previously.

ekryski commented 8 years ago

Wow. A year ago. Better late than never???

Thanks @bitfyre!