Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Setting variable defaults #1109
The only previous references to this I can find is from #313.
I'm currently working on variable prepopulation as part of require-less. For example, to load an existing less stylesheet with some specific variables already set. By using variable CSS selector names and allowing the variables to be set as part of the loading, one can use the variables to allow the entire less file to act as a modular unit itself, just as a mixin is a modular unit.
In the process, it would be useful if one could define defaults for global variables in a less file, in case any expected variables are missed.
Is there something like this already?
Also, unlike in #313, it would be nice to assign the default to the variable itself so that this doesn't need to applied with each instance of use as given in the initial solution here.
I've considered some syntax examples here:
Using an operator:
@mycolor: @mycolor || red;
Or using the guard expression system:
@mycolor: red when not (@mycolor);
Or using a function:
@mycolor: default(@mycolor, red);
Happy to discuss further.