I want to dynamicaly call .some-mixin() with some colors. This mixins should generate some styles, and when the colors are equals the special code should be generated.
Due to comprimation of final css code I want to do it by help variable, where can I store classes for the special code.
Maybe sample code will be more helpful:
.some-mixin(@newClass,@color,@color2){
.test-mixin(@newClass,@color,@color2);
.@{newClass}{
color: @color;
}
}
@classes: '';
.test-mixin(@newClass,@color,@color2) when (@color = @color2){
@classes: "@{classes}, @{newClass}";
}
.final-mixin(){
.@{classes}{
/*some styles*/
}
}
The call of mixins is generated by PHP and final code should looks like this:
.some-mixin("abc",#ffffff,#000000);
.some-mixin("xyz",#ffffff,#ffffff);
.some-mixin("jkl",#ff00ff,#ff00ff);
.final-mixin();
But when I want compile the LESS it shows infinite loop detected
Is this possible in LESS?
Any advice will be helpul.
withinstead ofwhen. Now it should be fully LESS code.$. I have never seen them used in Less before. If I correct all of them, the mixin and the calls work perfectly fine (when compiled using lesstester.com).test-mixinand.final-mixinseem to be a case where theextendfunction could be used. Maybe in addition to your current code, could you also explain what is your original requirement? It might help to see if there are better ways of doing it.infinite loopmessage. You cannot do@classes: "@{classes}, @{newClass}";in Less (unless using some hacks). It is a recursive variable definition.