0

In PHP, you can do the following.

$a = 'b';
$b = 'c';

echo $$a;

Resulting in

c

Can I do this in LESS?

@Red: #FF0000;
@Color: "Red";

div {
    color: @@Color;
}

The basis of this idea is that on my application you can change the color scheme, and when it's changed I was planning to execute this:

less.modifyVars({
  '@Color': 'blue'
});

If there is a better way to do this, I'd appreciate an example!

1 Answers1

1

You can use this syntax for that:

color: ~"@{@{Color}}";

Here is a working example:
https://codepen.io/anon/pen/YxxpOp

Or a simpler version using referencing variables (thanks to @seven-phases-max):

color: @@Color;
Dekel
  • 60,707
  • 10
  • 101
  • 129