Skip to content

Instantly share code, notes, and snippets.

@lomboboo
Created December 17, 2016 12:19
Show Gist options
  • Save lomboboo/93e267fc37e600cb0f9b3abd6a39e15b to your computer and use it in GitHub Desktop.
Save lomboboo/93e267fc37e600cb0f9b3abd6a39e15b to your computer and use it in GitHub Desktop.
Adding to LESS for loop with example
// ............................................................
// .for
.for(@i, @n) {.-each(@i)}
.for(@n) when (isnumber(@n)) {.for(1, @n)}
.for(@i, @n) when not (@i = @n) {
.for((@i + (@n - @i) / abs(@n - @i)), @n);
}
// ............................................................
// .for-each
.for(@array) when (default()) {.for-impl_(length(@array))}
.for-impl_(@i) when (@i > 1) {.for-impl_((@i - 1))}
.for-impl_(@i) when (@i > 0) {.-each(extract(@array, @i))}
==============================================================
EXAMPLE
==============================================================
@import "above-code.less";
.for(10); .-each(@i) {
.width-@{i} {width: @i}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment