I have 20-30 elements that should share the same color and font-family. Therefore I set it as a mixin. Now the cn website identified as <html class='cn'> should have the font of mango-arial and the jp should be hentai-arial.
I want the following sing CSS result file:
html.cn .div
{
color:green;
}
html.jp .div
{
color:yellow:
}
I’m, trying the following less code, each rule is defined in a separate language file:
-- in cn.less
html.cn
{
.textColor { color:green}
}
-- in jp.less
html.jp
{
.textColor { color: yellow}
}
-- in general.less
.div {.textColor;}
.someOtherElement1 { .textColor; otherstyles:here;}
.someOtherElement2 { .textColor; otherElem2Styles:here;}
...
Pay attention, I want all the language overrides in their separate less files.
New Answer
What you desire is not exactly an easy task. LESS is not quite designed to do it they way you intend. However, I do believe I found a way to get something that would work for you.
Define Your Language Specifics
Note that you will need to change how you have the languages defined, but they can be defined in separate files. Below is an example. Note:
html.lgcode wherelgis the language. That code needs to be defined in the.htmlAppendmixin portion.textColor, etc.). If you may want multiple properties for a class you are defining and you do not want to define them as a group (so you want to sometimes access them individually, sometimes as group), then you need to define a separate group getter (see thecolorPkggetter below for an example).Language Files Code
Core Variable and Mixins in Your Main File
You would import your language specific LESS files, then following that, have a few other things defined as noted below. Note:
Core Main File Code
Now Define Your Class Info
This is done in two stages for any classes that need the language aspects. First, call the property or property set from the language files, using the pattern matching name defined in the language files. Then define your other base class. Note that the “class” can be a selector string of any kind (see the third example).
Main File: Define Language Specific Class Code
Which Outputs This CSS
Original Answer
The original answer did not accommodate the structure of what the OP wanted, but I have left it here so that others might benefit.
LESS Code
One Solution
Organized under
htmltagAnother Solution
Organized on the
.divclass (not sure why you would want a class named that, but I went with it).Both Output This CSS