I only recently got involved in LessCSS, and I am facing what, in my opinion, is the main limitation, and I was wondering if there is a way to do this? I mean, I read somewhere that Sass allows user-defined functions, but will LessCSS do the same?
What I want to do:
@fs: 16; // either return the value .s(@t,@s,@u) { // return @t/@s*@u; }
The only way to understand this, but it is very limited, because I have to have several mixins:
.s(@t,@s,@u,@p) when (@p = margin-top) { margin-top: @t/@s*@u; } // margin[-top|-right|-bottom|-left] // padding[-top|-right|-bottom|-left] .s(@t,@s,@u,@p) when (@p = width) { width: @t/@s*@u; } .s(@t,@s,@u,@p) when (@p = height) { height: @t/@s*@u; }
I know that I can always modify the less.js file to add an interval function, such as the built-in round() or ceil() function. But this kills the ability to compile inactive files for production using LessPHP, Crunch, SimpLess.
Nathan L.
source share