When I use default less.js i can return a variable within a function like:
.function(@x,@y) {
.innerFunction() when (@x = @y) {
@output: @x
}
.innerFunction() when not (@x = @y) {
@output: @x/10;
}
.innerFunction() when (...) {
@output: @x + @y;
}
property: @output;
}
This is very practical to create more complex less functions but it does not work with lessphp... is there a way to return variables in lessphp?
Lessphp doesn't permit variables to leak out of the scope of the rules where they are defined.
The lessphp documentation says this:
The way you could reformat a mixin like this to work in both less.js and lessphp could be something along these lines:
and for example calling the mixin like this in LESS:
will give you the following CSS:
There are of course many different ways how to construct more complex mixins but the solution/approach will depend on what exactly you want to achieve in the specific case.