Skip to content

Accessing specific properties from rule-sets #76

Closed

Description

@bhavinkamani

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

Activity

  1. bhavinkamani commented on Jul 12, 2010

    @bhavinkamani
    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

  2. zvictor commented on Jul 6, 2011

    @zvictor

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

  3. sergeylukin commented on Aug 27, 2011

    @sergeylukin

    +1
    IMHO accessors may be very helpful

  4. nswaldman commented on Oct 26, 2011

    @nswaldman

    +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.

  5. gstoyanov commented on Jan 19, 2012

    @gstoyanov

    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!

  6. alex-netkachov commented on May 11, 2012

    @alex-netkachov

    +1

  7. Grigore147 commented on Dec 27, 2012

    @Grigore147

    +1

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

  8. seven-phases-max commented on Jan 16, 2016

    @seven-phases-max
    Member

    Merging to #1848.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions