I've got a .less stylesheet with the following construct:
@width:600;
.some-style
{
width:@{width}px;
}
and this gives the following error:
Expected '}' on line x in file '..\styles.less'
I need those braces, because I need to distinguish the variable from the following px
suffix (@widthpx
doesn't work because then it looks for a variable called widthpx
). And I can't use a space because 600 px
isn't valid css. Using parentheses instead of curly braces doesn't work either.
What am I doing wrong here?
Update: I installed the latest version of .less from the Package Manager, and now it works a little better, but with a fatal flaw:
width:@(width)px; <--note the parentheses
now compiles, but emits this CSS:
600 px <--note the space, which is invalid CSS, thus useless.
Solved: ScottS pointed me to the solution. In addtion to his two methods, it looks like the compiler can do math on string. So this works:
@width:600px;
.some-style
{
width:@width / 2; <--correctly emits "300px"
}