Forum:Arbitrary template arguments

Let's say I have a template that takes an arbitrary number of arguments, numbered arg1 to argn, and does something with them and a related variable. Is there a "foreach" style operator or way to do something similar using template magic? The way I'm currently doing it is:

Which continues up to a number that I figure no one would surpass. If there's a way to consolidate this down to, say, "foreach_operator args dosomething", that would be nice. I saw a Foreach template on MediaWiki that looked intriguing, but I'm not sure if the way I want to use it is legal. Can I give it empty arguments, like say arg1 to arg30, where the empty arguments are just ignored? And can I curry it, turning it into:

Into something where SpecialTemplate extracts the argument number and does something with otherarg1, otherarg2, ..., otherargn? The hangup I'm having here is I'm not sure if that sort of currying is even possible. Will #replace work here, so we get a SpecialTemplate like:

fillertext,

Or does that not do what I think it does?

Anyone have any advice here, or is the way I did it where you just expand the ifs out for like 10 options the only way? Surgo 06:28, 13 August 2009 (UTC)