I am a newbie at less. I am trying to pass css property as an argument like this
.border(@position:"left",@color: #ddd){
border-@position :1px solid @color;
}
means that every time I type
.border(right,#efefef);
it should output
border-right:1px solid #efefef;
I am using winless to compile the code Winless version 1.8.3 and LESS.js version 1.7.3
Winless compiler gives error
ParseError: Unrecognised input in "My-file-path" on line "line No. etc"
in my search for the answers I found these questions they are about 1 year old and they say that it is not possible (at that time) because it is not supported by LESS is it possible now?
How to pass a property name as an argument to a mixin in less
the answer in this question uses a hack to achieve the goal should I use this
.mixin(@prop, @value) {
Ignore: ~"a;@{prop}:@{value}";
}
Send properties as argument for mixin
ANSWER:
found the answer here thanks for one of the comment
this solved the problem I almost got it right when I asked the question just had to add curly braces to the css property argument
.border(@position:"left";@color:#ddd){
border-@{position}:1px solid @color;
}
that can be used
.border(right,#efefef)
so this compiles to :
border-right: 1ps solid #efefef;
Using variables in property names in LESS (dynamic properties / property name interpolation)