Standard lesscss mixin:
.box-shadow(@val) {
-moz-box-shadow: @val;
box-shadow: @val;
}
However, in pure CSS I'm able to use several box shadows on one element, e.g.
#myBox {
box-shadow: inset 0px 1px 0px white, 0px 0px 5px #aaa;
-moz-box-shadow: inset 0px 1px 0px white, 0px 0px 5px #aaa;
}
To ie. create an inset and glow effect. Of course I want to use lesscss to remedy the vendor-prefix curse in this case too, but
.box-shadow() {
-moz-box-shadow: @arguments;
box-shadow: @arguments;
}
#myBox {
.box-shadow(inset 0px 1px 0px white, 0px 0px 5px #aaa);
}
will render
#myBox {
box-shadow: inset 0px 1px 0px white 0px 0px 5px #aaa;
-moz-box-shadow: inset 0px 1px 0px white 0px 0px 5px #aaa;
}
(notice the missing commas after white
)! Which is syntactically incorrect. Is there any way to trick lesscss into concatenating multiple arguments with ,
instead of ? I thought this should be a more-or-less standard problem, but haven't found any canonical solutions...
If you are using lessphp (http://leafo.net/lessphp/) for server side compilation (instead of the javascript lesscss compiler from http://lesscss.org) you could bind a php function and use it to change the character used for the concatenation.
Example lesscss code:
Bound php function:
And to do the binding and compile the lesscss code:
Output:
Tested with lessphp 0.4.0.
Using the solution found here works with one AND multiple arguments:
If you escape the argument string as a string literal, it will carry the comma over just as you want:
Outputs:
Use an escaped string
Or a javascript escape
Less 1.2.0 and below:
Less 1.3.0 and above (requires and uses
...
variadic specifier):The author's recommended way is an intermediate variable: