Skip to content

Rulesets as property values (to be parsed as ~DRs). #3379

Open
@seven-phases-max

Description

@seven-phases-max

After a more relaxed parsing of property-value rules introduced in recent Less version the following code is now "valid" (i.e. compiles w/o errors):

@values: {
    bar: {a: b};
    baz: {c: d};
};

It would not be unexpected for someone to think this code is basically a map similar to:

@values: {
    @bar: {a: b};
    @baz: {c: d};
};

except the obvious property/variable difference.

So that the one would expect similar behavior of both structures in snippets like:

result: @values[bar][a];
// or
each(@values, ...

Currently however, everything inside @values (of the property-based snipped) results in a single anonymous-like value.


So the feature request is to parse
bar: {a: b}; just like
@bar: {a: b}; is parsed
(Implementation details may vary, e.g. it does not have to be a DR, just whatever map/each compatible rule-value->ruleset structure would be fine I think).


(To illustrate the use-case) I stepped into this when writing an answer for this SO Q: https://stackoverflow.com/a/55304379/2712740
Basically there it would be reasonable (in a perfect world) to expect one (me for example) to prefer to use light/dark instead of @light/@dark just to minimize the @-noise and to get rid of the weird things like replace(@key, '@', '.');). But the primary idea is about consistency (it's not this or another specific use-case is really important).

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