I try to use mixin guards with when
condition, but during compiling I get the following error:
.mixin is undefined
.mixin (@color) when (isstring(@color)) {
//some code
}
.mixin(#008000);
When I remove the when
condition it works. Whats the problem here?
The problem is that we have variables inside our less-files which are defined in one compile-process. But during another compile-process this variables are not defined because we need a little bit dynamic here.
So I have to check if the variable is defined. When I try it over
$variables = [
'testColor' => '#fff111',
];
$lessc->setVariables($variables);
$cachedCompile = $lessc->cachedCompile($publicPath . $inputFile);
and
.mixin (@color:none) when (iscolor(@color)) {
color: #fff;
}
.mixin(@testColor);
Everything works. But when I remove the testColor
variable in the variable-array it crashes because it isn't defined.