I am not aware of less natively having a functionality of applying/looping through all arguments of a mixin, but there is a lot of options how to overcome this.
You can add a custom javascript function to the less block that does what you want. Here is a link to a nice reference for custom functions.
But you can also just build a little loop in less:
// for loop
.for(@l,@obg,@i:1) when (@l > @i) {
@nbg: `@{url}[@{i}]`;
@bg: ~"@{obg}, @{nbg} @{rest}";
.for(@l, @bg, @i + 1);
}
// multiple background urls + additional bg properties
.bgmixin(@url, @rest){
@num: unit(`@{url}.length`);
@bg: ~`@{url}[0]` @rest;
.for(@num, @bg);
background: ~"@{bg}";
}
// defining bg urls
@url: 'url("../img/war_top_baner_gp.png")', 'url("../img/war_header_bg.png")';
// including the bgmixin in .class
.class{
.bgmixin(@url, center top no-repeat transparent);
}
And the output is
.class {
background: url("../img/war_top_baner_gp.png") center top no-repeat transparent,
url("../img/war_header_bg.png") center top no-repeat transparent;
}
If I understood you right this is what you wanted.
Edit: I just wanted to add here that my idea here was to find a more general solution that is actually looping/recursing through array elements, which makes it easy to use different attributes with their respective images - so you feed the function an array of urls and an array of the other attributes. Here I'll try to illustrate the idea:
.for(@l,@obg,@i:1) when (@l > @i) {
@nbg: `@{url}[@{i}]`; @nattr: `@{attr}[@{i}]`;;
@bg: "@{obg}, @{nbg} @{nattr}";
.for(@l, @bg, @i + 1);
}
.bgmixin(@url, @attr){
@num: unit(`@{url}.length`);
@bg: ~`@{url}[0]` ~`@{attr}[0]`;
.for(@num, @bg);
background: ~"@{bg}";
}
@urls: "url('../img/centered_image_bg.png')", "url('../img/left_image_bg.png')";
@attr: "center top no-repeat transparent", "left top y-repeat";
.class{
.bgmixin(@urls, @attr);
}
and the output will look like this:
.class {
background: url('../img/centered_image_bg.png') center top no-repeat transparent,
url('../img/left_image_bg.png') left top y-repeat;
}