Update: Take a look at Guard Expressions in LESS - maybe this can help a bit, you can create conditional conditional expressions, but you need to use mixins.
I understand your point of view, but, on the other hand, I would apply this problem in a different way. Here is another simplified example: you define variables for differences in both cases, and then import as you like - for example, put in master-ltr / master-rtl and import the remaining stylesheet after:
// master-ltr.less // LTR: @sidebar-pos-left: 10px; @sidebar-pos-right: 0px; @content-float: left; ... @import 'styles.less'; // your styles.less would have: .content { float: @content-float; ... } .sidebar { position: relative; left: @sidebar-pos-left; right: @sidebar-pos-right; ... }
.. or maybe more efficiently - create a separate file with vars-ltr / rtl, and then import it into your master-ltr / rtl.
Not sure how complicated the layout is, but maybe this gives you something you can use?
I tried this using String Interpolation , but it looks like variables can only be embedded in the "variable" definitions. Maybe I'm wrong, maybe people know how to achieve this.
I would do it a little differently, not because it is impossible with LESS, but because of the organization of the code and the general more reasonable approach (it is not good to call something βleftβ when sometimes it will be actually βrightβ :)
For your second problem with position:relative
, here is my take:
<div class="element element-ltr">...</div> .element { position: relative; &.element-ltr { left: @element-side-position; } &.element-rtl { right: @element-side-position; } }
This solution seems to be OK, but if you are a huge stylesheet, you will have many additional classes for -ltr and -rtl. Not a big pain, but you could make it even more useful by expanding the -ltr / -rtl area to the parent containers (e.g. header / content / sidebar / footer) and then adjust from there. They can have a lot in common, such as background, colors, font size .. and you will just work on the differences in their versions of -ltr / -rtl.
Also, read the LESS Namespaces , they can offer you even more organization options.
Hope this helps!