LESS mix variable into attribute name in an attrib

2019-08-05 01:53发布

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

标签: css less
1条回答
叛逆
2楼-- · 2019-08-05 02:31

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}"] {
        // ...
    }
}
查看更多
登录 后发表回答