How to set a var with dynamic name in less mixin

58 Views Asked by At

I am trying to create a mixin that will set a var with a dynamic name.

// less File B
.varMaker(@varname, @value){

  // Here I would like to set a var with the name @varname 

}


// less File A
.varMaker(foo,bar);

My mixin is defined in a file B and called in a file A.

In File A I'd like to use the returned var like this :

// less File A
.varMaker(foo,bar);
background: @foo;

// I would like it compile in
background : bar;

I precise that I can not display the property and its value directly in my .varMaker mixin because after setting @foo var, it is supposed to be pass to an other mixin.

I succeed to use dynamic var name and a mixin that set a var separately but I am not able to do both.

I am compiling less code using php oyejorge and errors messages are not always explicit.

0

There are 0 best solutions below