kirisetsz
kirisetsz

Reputation: 105

LESS mix variable into attribute name in an attribute selector expression

How can I implement the following syntax correctly?

.jacket(@classname, @attrname, @value) {
    .class-prefix-@{classname}[some-prefix-@{attrname}~="@{value}"] {
        //                                 ^Error From Here
        // Attributes
    }
}

lessc shows that there is an SyntaxError: expected ']' got '@'

Upvotes: 1

Views: 1793

Answers (1)

seven-phases-max
seven-phases-max

Reputation: 11820

It seems like a bug actually, this workaround should do the trick:

.jacket(@classname, @attrname, @value) {
    @attr: ~'some-prefix-@{attrname}';
    .class-prefix-@{classname}[@{attr}~="@{value}"] {
        // ...
    }
}

Upvotes: 3

Related Questions