less.js icon indicating copy to clipboard operation
less.js copied to clipboard

How do I use a variable in less js as a command that appears before a parenthesis?

Open desbest opened this issue 4 years ago • 0 comments

How do I use a variable in less js as a command that appears before a ( bracket or parenthesis? I asked on Stack Overflow and couldn't get any help.


.breadcrumb li:nth-child(2) a       { background:  darken(@breadcrumbrootback, 5%); }
.breadcrumb li:nth-child(2) a:after { border-left-color:  darken(@breadcrumbrootback, 5%); }

I would like to change darken( to @breadcrumbcolouraction( so the command is chosen based on a variable (so it could be either lighten or darken based on the value or a variable). How do I do this?

@breadcrumbcolouraction: "darken";
@breadcrumbcolouraction: "lighten";

In less version 4.1.1 if I changed darken to the variable @breadcrumbcolouraction, the less file would fail to compile.

desbest avatar Feb 25 '21 19:02 desbest