Skip to content

Accessing specific properties from rule-sets #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bhavinkamani opened this issue Jul 12, 2010 · 9 comments
Closed

Accessing specific properties from rule-sets #76

bhavinkamani opened this issue Jul 12, 2010 · 9 comments

Comments

@bhavinkamani
Copy link

Hi,

Does less.js allows accessing specific properties from a rule-set? I was trying with following less-css

#color {
    @brand-color: #EEE;
}

html,body {
  background-color: #color[@brand-color];
}

However, it is giving syntax error. From official LESS documentation this appears to be the correct syntax (Ref: http://lesscss.org/docs - Namespaces & Accessors).

Thanks for making a truly rocking solution.

Regards
Bhavin

@cloudhead
Copy link
Member

@bhavinkamani
Copy link
Author

Hi,

I saw couple of issues related to this topic. I believe it has been scrapped for the sake of simplicity and in favor of global variables.

Given following example, accessors DRY up variable names and makes it look more readable especially when there are too many global variables. IMO, its a nice option to have unless it makes the implementation more complicated.

// #color[@brand]
#color {
    @brand: #DDD;
    @background: #EEE;
    @title: #555;
}

// global Variables
@brand-color: #DDD;
@background-color: #EEE;
@title-color: #555;

Looking forward to hearing your thoughts...

Regards
Bhavin

@zvictor
Copy link

zvictor commented Jul 6, 2011

I agree with bhavinkamani.
Accessors are very important. I still use the old Less because of them.

@sergeylukin
Copy link

+1
IMHO accessors may be very helpful

@nswaldman
Copy link

+1
It has come to the point where trying to work around the lack of accessors gets more and more complicated. This feature would be really, really useful.

@gstoyanov
Copy link

This is the first open issue on accessors that I found, so I'll comment here.

I agree with the others - I think accessors can be very useful for grouping variables together in bundles - e.g. colors, images, font sizes etc.

However, if they're not coming back, maybe at least the docs could be updated to reflect the change, because right now it's kind of misleading. This was the feature that made me switch from dotless to less.js and now that it's not here I'm a bit disappointed, although I’m not sorry I switched.

Anyway, with or without accessors less is great so keep up the good work!

@alex-netkachov
Copy link

+1

@Grigore147
Copy link

+1

Any idea when this would be implemented back? It could be very useful.

@seven-phases-max
Copy link
Member

Merging to #1848.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants