I am trying to implement a recursive loop in LESS 1.3.1. Never you mind what the mix-in is supposed to do (it has something to do with colors) in the end, but do mind why the recursive loop fails.
@iter: 4;
.loop(@index, @n) when (@index <= @n) { // throws "expected expression"?
.foo@{index} { color: black; }
.loop(@index + 1, @n);
}
.loop(@index, @n) when (@index > @n) {
.terminated { color: white; }
}
.loop(1, @iter);
The mix-in .loop is supposed to do 4 iterations and then terminate, doing a .terminated {} or something.
You have your = and > the wrong way round
Less Mixin Guards Documentation
“The full list of comparison operators usable in guards are: > >= = =< <. Additionally, the keyword true is the only truthy value, making these two mixins equivalent:”
should be