Inside ASP.net I'm serving a dynamic less stylesheet with dotless. I'm using a query string to pass in the variables.
<link rel="stylesheet" href="~/Content/style.less?&color1={{var1}}&color2={{var2}}>
The variables are already declared in LESS (color1: red, color2: blue), I would like to override these values if they are passed in the query string. This does not work right now because dotless actually prepends the variables from the query string, and less uses the last declared variable.
I see two options, but I don't how to achieve these:
- Append the variables instead of prepend them. This is how dotless does the prepending: https://github.com/dotless/dotless/blob/master/src/dotless.Core/Engine/ParameterDecorator.cs
Set the less variables color1 and color2 as optional - only if they're not set before. Something like:
color1: color1 || red;
Does something like this exist in LESS (/dotless)?
Less do not have the option to set default values for variables, see http://lesscss.org/features/#variables-feature-default-variables for the reason that you don't need them, already mentioned by you the last declaration wins (and Less uses Lazy Loading).
But on https://github.com/dotless/dotless/wiki/Parameters i found:
Setting this option to
false
should fix your issue: