Prepocessor (Less) - Variable @Arguments

3

Assuming I have the following mixin with following arguments:

.font-style(@size: 1.2em, @style: 100, @leading:1.4em, @color: #efefed)

Now I want to play this mixin passing the arguments that I define for a specific class. Ex:

.myClass{ .font-style(2.2em,...) }

Doubt : If I want to modify only the @size and @color arguments, I'd need to repeat the default (@arguments) of the order Ex:

.font-style( @==a -> "mudei valor", @==b "default", @==c "default", @==d -> "mudei valor )

Or is it a different way that I can use the defaults without repurposing and change what I really need?     
asked by anonymous 28.07.2015 / 19:01

1 answer

1

Yes, when creating your mixin with parameters using the variable "@arguments" you must specify a default value for each of them.

So when calling your mixin you do not have to pass the values in a special order and even omit the defaults. Ex:

Set Mixin

.font-style(@size: 1.2em, @style: 100, @leading:1.4em, @color: #efefed);

Call Mixin

.myClass{ .font-style(2.2em,2.4em) }

Note the omission of the other parameters.

Optional parameters (non-explicit value) need to be passed when there is a call. Ex:

.font-style(@size: @size, @color: @color);

Sources:
link link link

    
03.08.2015 / 14:43