Created
December 17, 2016 12:19
-
-
Save lomboboo/93e267fc37e600cb0f9b3abd6a39e15b to your computer and use it in GitHub Desktop.
Adding to LESS for loop with example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ............................................................ | |
// .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