Question

I am attempting to use lesscss to build a templating system where each template has 3 or 4 alternative colour schemes.

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

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

So, I only have one main.less stylesheet to maintain which contains all the main styles, and uses the variables set for colour codes. I can then create a seperate colour.less file for each colour scheme.

Only problem is when I try to do this I get a Less::VariableNameError which indicates that LESS is parsing the @imports BEFORE it parses the variables.

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

Was it helpful?

Solution

In reference to your tweet, yes, this would work as you expect in Sass. I'm actually kind of surprised that it doesn't work in Less.

OTHER TIPS

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

Its not a big change to do in the original Less ruby version and if you fancy tinkering with the source I can point you in the right direction.

Out of interest, without been traitorous to the Less team I quite like the SASS syntax now and there are additional things such as conditional statements and loops that you cant (yet) do with Less.

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

Seems like this isn't a problem any more, or at least not for me using "dotless" for .net?

Seems to work fine now with latest LESS.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top