I've recently started experimenting with LESS. I decided to create rules for elements with numeric IDs, leading me to this code snippet:
@myRule: {padding: 0;};
.myLoop(@c, @rules) when (@c >= 0) {
.myLoop((@c - 1), @rules);
&[id*=@{c}] { @rules(); }
&[name*=@{c}] { @rules(); }
}
.myClass {
.myLoop(2, @myRule);
}
when compiled, it produces:
.myClass[id*=0] {
padding: 0;
}
.myClass[name*=0] {
padding: 0;
}
.myClass[id*=1] {
padding: 0;
}
.myClass[name*=1] {
padding: 0;
}
.myClass[id*=2] {
padding: 0;
}
.myClass[name*=2] {
padding: 0;
}
Is there a way to make it compile like this instead:
.myClass[id*=0],
.myClass[name*=0],
.myClass[id*=1],
.myClass[name*=1],
.myClass[id*=2],
.myClass[name*=2] {
padding: 0;
}
I've searched for solutions like 'extending mixins', 'parametric extend' or 'extending ruleset', but they all seem to have unresolved issues. I'm reaching out to those more knowledgeable in less to see if there is a workaround.