P.Brian.Mackey P.Brian.Mackey - 4 months ago 25
Less Question

Using JavaScript in Less

@root: "/images";
@app-root: `"@{root}".toUpperCase()`;

#form {
background: url("@{app-root}/back.jpg");
}


Running this in LESS2CSS I get error:


SyntaxError: JavaScript evaluation error: Unexpected string from
""/images"".toUpperCase()
on line 2, column 12:

1 @root: "/images"; 2 @app-root:
"@{root}".toUpperCase()
; 3


Supposedly all I need to run JS in LESS is a set of backticks. So, why does this fail?

Answer

Remove the double quotes, and you are good to go:

@app-root: `@{root}.toUpperCase()`;

check here

Comments