I wrote some helper functions in root less file:
@randomFunctions : ~(function(s){ var round = function(n,c){ c = c|0; return Math.round(n * Math.pow(10,c))/Math.pow(10,c); }; var random = function(s,e){ return Math.random() * (e - s) + s; }; global.r = function(s,e,u){ return round(random(s,e)) + u; }; return 'randomFunctions'; })(this);
then I could generate random numbers using these functions:
.r{ opacity : ~r(0,1); } outputs .rr{ opacity : 0.3; }
but in a mixin:
.r(@i){
.r@{i} { opacity : ~r(0,1); }
}
.r(1);
compiler tells me 'Can not found r function in [object Object]'
so I guess the javascript evalution context inside a mixin is different with the context in root.
Will this be fixed in next version? or just add another way to pass a function inside mixin so I can release the power of javascript in less file?