Is there a way to use variables in less ~ operator, like
~"calc(70% - @spacing)";
When I have tried it it only works with static values like
~"calc(70% - 10px)";
Can I get the string to be evaluated prior to beeing set as a property.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To disable the calculation which LESS does automatically when discovering a
-between two numeric values but still being able to use variables, you can write one of the following:1) Only escape the operator that triggers the calculation and use the variable like you normally do
2) Escape the whole expression and interpolate the variable with the
@{padding}notationI prefer the second version, since it resembles javascript’s template literals and looks a bit cleaner, but either way works just fine.
Both solutions disable the automatic Less calculation and compile to the correct result: