variable in name

49 views
Skip to first unread message

Gidon

unread,
May 24, 2010, 6:59:27 AM5/24/10
to DotLess (Less Css for .NET)
Hi,

INTRO:
I'm working on a website that supports both LTR and RTL. So far I made
two stylesheets, one for LTR and one for RTL. The RTL stylesheet
imports the LTR stylesheet and "overrides" those items that are RTL
specific. (padding-right vs padding-left etc).

float: right/left I manage by having a variable called @side (and
@side-opposite) and setting it to the correct side in both stylesheets
(in RTL it is "right", and in LTR it is "left"). In my LTR stylesheet
I write : float : @side

That was the intro....
QUESTION:
I would also like to eliminate the "overriding" issue, to keep my code
more DRY.

The ultimate thing would be if I could write:

.bla {
padding-@side: 20px;
}

I thought I might use the format function, but it only allows me to
format the value of the property, and not the key. ( as in
format("padding-{0}: 20px", @side) ).

Is there anything out there , that I oversaw, that allows me to do
this or something similar?


Thanks a lot (again).
Gidon

James Foster

unread,
May 24, 2010, 10:18:21 AM5/24/10
to dot...@googlegroups.com
I've been thinking about that. Imagine the following

@var: xyz;
.class-#{@var} {
property-#{@var}: "abc #{@var}";
}

This is based on a feature from sass. Where sass sees the #{}
construct it evaluates the contents as an expression. So you could put
operations and functions I'm there. The above would output

.class-xyz {
property-xyz: "abc xyz";
}

We'd have to think carefully about syntax but I'd love to have
something like this in dotless.

Thoughts?

Gidon

unread,
May 24, 2010, 10:37:00 AM5/24/10
to DotLess (Less Css for .NET)
I'm all for it.

The only thing is that besides my use, I don't see a lot of other uses
for it. (although probably my case is probably helpfull for many RTL
programmers).

BTW, does .LESS have IF statements? Because than I could solve the
same issue as follows:


@direction: ltr;

.fn-padding-left(@value: 0)
{
[if @direction = ltr]
padding-left: @value;
[else]
padding-right : @value;
[endif]
}

this is also a good option, and i can see many other uses for this.

Gidon

unread,
May 31, 2010, 6:00:01 AM5/31/10
to DotLess (Less Css for .NET)
Is there a plan to implement this?

On May 24, 5:18 pm, James Foster <james....@gmail.com> wrote:

James Foster

unread,
May 31, 2010, 6:14:11 AM5/31/10
to dot...@googlegroups.com
No, not in the short term at least. And not without careful consideration of the syntax.

It might be an idea to post an issue here asking about this.


because if it makes it into less.js it will definitely make it into dotless.

James
Reply all
Reply to author
Forward
0 new messages