This is my initial context.
I receive from a third party a list of sass variables, and I can't change the shape of this data:
$green-primary-1: green;
$green-secondary-2: aqua;
$green-secondary-3: grey;
$red-primary-1: green;
$red-secondary-2: aqua;
$red-secondary-3: grey;
$blue-primary-1: green;
$blue-secondary-2: aqua;
$blue-secondary-3: grey;
// data represented here is fake
// ...
Then I've a function, that includes some logic and it returns the string of the name one of the previous sass variables, listed above:
@function get_var_name($param1, $param2) {
// logic
// ...
@return "green-secondary-2";
}
And this function is used in some sass code to (try to) retrieve the content precisely of the specific named variable:
span {
color: #{#{get_var_name('param1', 'param2')}};
}
and I'm expecting this output
span {
color: aqua;
}
Instead I'm getting this:
span {
color: green-secondary;
}
Please, do not provide css variables approach as answer, or maps solution for my initial source of data or something different from the question context.
My mandatory input is some sass variables. My mandatory output is css property handled dynamically with these variables names.
Am I not seeing something obvious? Because I can't really make it work... And I feel it should be something stupid. Thanks anyway