This is an auxiliary module intended to be invoked by templates; it permits templates to support an infinite number of parameters by repeating a block of wikitext multiple times. This module works with named as well as unnamed parameters, can handle multiple named parameters at the same time, and supports defaults,
If you want to use this module in your template: take the block of wikitext that you want to be repeated for infinite parameters, wrap it in <nowiki>
, and pass that as the module's first parameter; then, choose a "base" parameter such that the module will stop repeating the wikitext if the parameter wasn't defined by the user, and pass its name as the second parameter. Example usage:
...<nowiki>{{</nowiki>#invoke:ArgRest|''main''<nowiki>|<nowiki>...{{{named-2-a}}}...{{{named-2-b|default}}}...</nowiki>|named-2-a}}</nowiki>
Afterwards, the module will "fill in" parameters with larger numbers than the ones originally given; i.e. in the above example, the module would allow the containing template to receive parameters <nowiki>{{{named-3-a}}}</nowiki>
, <nowiki>{{{named-3-b}}}</nowiki>
, <nowiki>{{{named-4-a}}}</nowiki>
, etc.
Note: You MUST wrap the first parameter in <nowiki>
; otherwise, Wikipedia processes all wikitext and HTML syntax before the module receives it, which makes it impossible to use pattern matching due to the resulting pollution. If you do, the module will give this error:
If the (imaginary) template {{PlusMinusLoop}} has the following code:
{{{plus1}}} - {{{minus1}}}{{#invoke:ArgRest|main|<nowiki> + {{plus2}}} - {{{minus2|5}}}</nowiki>|plus2}}then
will yield 0 - 1 + 1 - 2 + 3 - 5
. The - 5
is present because |minus3
defaulted to 5, but 21
never appears because, although |plus5
is defined, |plus4
isn't, so the module halts there.
This module has a few submodules that serve as "partners" for the module, to help it in certain scenarios:
This submodule allows ArgRest to be used without needing to be inside of a template.
If you try to use ArgRest to generate parameters inside of an outer template (e.g. <nowiki>{{enum{{#invoke:ArgRest|<nowiki>|{{{1}}}&lt;/nowiki>|1}}}}</nowiki>
), it will normally fail to do so because the outer template won't get processed after ArgRest is done parsing; this submodule can fix that (albeit in a rather scrappy way) by simply processing the outer template one extra time.
Be wary when using ArgRest wrapped inside of an outer template; it hasn't quite been thoroughly tested in such scenarios, and should be watched carefully when it is used this way.
This module currently suffers from a few limitations:
<nowiki>{{{parameter1| {{{alias1|default}}} }}}</nowiki>
will fail to be recognized by the module as a parameter.<nowiki>{{{named-3-1}}}</nowiki>
as equivalent to <nowiki>{{{named-3-3}}}</nowiki>
.<nowiki>...{{{1}}}...{{{2}}}...</nowiki>
won't work.