How to transfer variables from one lesscss stylesheet to an included stylesheet?

I am trying to use lesscss to create a template system where each template has 3 or 4 alternative color schemes.

So, for example, I could have a red.less stylesheet that looks like this:

 @main_colour: #ff0000; @import 'main.less'; 

So, I have only one main.less for support, which contains all the basic styles, and uses the variables set for color codes. Then I can create a separate colour.less file for each color scheme.

Only problem is when I try to do this. I get Less::VariableNameError , which indicates that LESS parses @imports before it parses variables.

Is there a way around this or any other way to achieve the same end result?

+4
source share
4 answers

Regarding your tweet , yes, it will work the way you expect in Sass . I am really surprised that it does not work in Less.

+2
source

I assume the Less guys want to keep the .Less file atomic and independent of the external environment settings. This was what I expected, but I also didn’t like it, so our .NET port http://www.dotlesscss.com will allow you to do this by default,

Not a big change in the original version with less ruby, and if you want to chat with the source, I can point you in the right direction.

Out of interest, without betrayal for the Less team, I really like the SASS syntax, and there are additional things like conditional statements and loops that you cannot do (yet) with Less.

@ nex3 - you guys should stop competing and just work together.

+1
source

It seems like this is no longer a problem, or at least not for me, using "dotless" for .net?

0
source

Seems to work fine with the last LESS now.

0
source

All Articles