I am attempting to create a recursive loop in LESS 1.3.1 that involves manipulating colors. However, despite my efforts, the recursive loop fails for some reason.
@iter: 4;
.loop(@index, @n) when (@index <= @n) { // Why does it throw an "expected expression" error?
.foo@{index} { color: black; }
.loop(@index + 1, @n);
}
.loop(@index, @n) when (@index > @n) {
.terminated { color: white; }
}
.loop(1, @iter);
The purpose of the .loop
mixin is to iterate four times and then terminate by applying a .terminated {}
style rule or something similar.