Reputation: 1343
How can I change the value from a LESS variable (#333) with ASP.NET
@color: #333;
.logo {
color: @color;
}
.div {
background: @color;
}
I'm trying to dynamicaly edit a variable value in a LESS-file using the 'Code Behind' so that when the variable @color get changed using coding, all the elements using that variable will also change.
... codebehind > change @color = #666;
Upvotes: 0
Views: 790
Reputation: 49044
I think it depend how you do compile your Less code.
When your are using .less you can not use modifyVars by default. modifyVars requires lazy loading and last declaration wins. .less got the disable-variable-redefines
option:
Makes variables behave more like less.js, so the last variable definition is used
In Less you can put a variable definition afterwards which overrule all earlier definitions due to lazy loading and last declaration wins. See also
modifyVars
does not else than putting the variable definition afterwards.
When you are compiling your code node-less (web essentials does) you should be able to use the modifyVars
option.
Or alternatively when you normally compile main.less you can try to compile a new file (dynamically edit / generated):
@import "main.less"
@color: red;
Upvotes: 1