Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:ArgRest/doc
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Module rating|alpha}} <!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata --> 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, == Usage == 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 <code class="cm-mw-htmltag-name"><nowiki></code>, 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: :<code>...<nowiki>{{</nowiki>#invoke:ArgRest|''main''<nowiki>|<nowiki>...{{{named-2-a}}}...{{{named-2-b|default}}}...</nowiki>|named-2-a}}</nowiki></code> 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 <code><nowiki>{{{named-3-a}}}</nowiki></code>, <code><nowiki>{{{named-3-b}}}</nowiki></code>, <code><nowiki>{{{named-4-a}}}</nowiki></code>, etc.<br /> <strong>Note: You MUST wrap the first parameter in <code class="cm-mw-htmltag-name"><nowiki></code>;</strong> 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: :{{error|Lua error in Module:ArgRest at line 8: <nowiki> tags missing from first parameter.}} === Example === If the (imaginary) template <nowiki>{{PlusMinusLoop}}</nowiki> has the following code: <pre> {{{plus1}}} - {{{minus1}}}{{#invoke:ArgRest|main|<nowiki> + {{plus2}}} - {{{minus2|5}}}</nowiki>|plus2}} </pre> then :{{tlc|PlusMinusLoop|plus1{{{=}}}0|minus1{{{=}}}1|plus2{{{=}}}1|minus2{{{=}}}2|plus3{{{=}}}3|plus5{{{=}}}21}} will yield <code>0 - 1 + 1 - 2 + 3 - 5</code>. The <code>- 5</code> is present because <code>|minus3</code> defaulted to 5, but <code>21</code> never appears because, although <code>|plus5</code> is defined, <code>|plus4</code> isn't, so the module halts there. === Helpful templates === There are a few templates that can used with this module to help it adapt to certain scenarios: * {{tl|Call wikitext}}: This template allows ArgRest to be demoed without the need to create a template. ** For example, <code><nowiki>{{Call wikitext|sourceCode=<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1}}}&lt;/nowiki>|1}}</nowiki>|foo|bar}}</nowiki></code> outputs <code>{{Call wikitext|sourceCode=<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1}}}</nowiki>|1}}</nowiki>|foo|bar}}</code>. * {{tl|Expand wikitext}}: If you try to use ArgRest to generate parameters inside of an outer template (e.g. <code><nowiki>{{enum{{#invoke:ArgRest|main|<nowiki>|{{{1}}}&lt;/nowiki>|1}}}}</nowiki></code>), it will fail to do so because the outer template won't get processed after ArgRest is done parsing. This template fixes this by invoking the parser to process the outer template. ** For example, a template defined as <code><nowiki>{{Expand wikitext|{{enum{{#invoke:ArgRest|main|<nowiki>|{{{1}}}</nowiki>|1}}}}}}</nowiki></code> called with the arguments <code><nowiki>{{__TEMPLATE__|foo|bar|Baz}}</nowiki></code> would output <code>{{Call wikitext|sourceCode=<nowiki>{{Expand wikitext|{{enum{{#invoke:ArgRest|main|<nowiki>|{{{1}}}</nowiki>|1}}}}}}</nowiki>|foo|bar|baz}}</code> where as one defined as <code><nowiki>{{enum{{#invoke:ArgRest|main|<nowiki>|{{{1}}}</nowiki>|1}}}}</nowiki></code> would output <code>{{Call wikitext|sourceCode=<nowiki>{{enum{{#invoke:ArgRest|main|<nowiki>|{{{1}}}</nowiki>|1}}}}</nowiki>|foo|bar|baz}}</code>. ** <strong>WARNING:</strong> ArgRest may become highly unstable if you use it this way, and is rather likely to not work as expected in these scenarios. If you do use it like this, heavy caution should be taken. === Note === 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. == Limitations == This module currently suffers from a few limitations: * It cannot handle aliases; <code><nowiki>{{{parameter1| {{{alias1|default}}} }}}</nowiki></code> will fail to be recognized by the module as a parameter. * It cannot handle parameters with names that contain two or more distinct numbers; the module's pattern matching is ignorant of this possibility, and will treat something like <code><nowiki>{{{named-3-1}}}</nowiki></code> as equivalent to <code><nowiki>{{{named-3-3}}}</nowiki></code>. * It cannot handle multiple parameters that have different numbers; similarly to the above example, all numbers are converted by the module into the same number, so <code><nowiki>...{{{1}}}...{{{2}}}...</nowiki></code> won't work. == See also == * {{mfl|params|with_name_matching}}, {{mfl|params|for_each}} * {{mfl|for nowiki|template}} * {{tl|for nowiki}} <includeonly>{{Sandbox other|| <!-- Categories below this line; interwikis at Wikidata --> [[Category:Template metamodules]] }}</includeonly> <noinclude> [[Category:Module documentation pages]] </noinclude>
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Call wikitext
(
edit
)
Template:Error
(
edit
)
Template:Mfl
(
edit
)
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Template:Pp
(
edit
)
Template:Protection padlock
(
edit
)
Template:Template link
(
edit
)
Template:Template link code
(
edit
)
Template:Tl
(
edit
)
Template:Tlc
(
edit
)
Module:Arguments
(
edit
)
Module:Error
(
edit
)
Module:File link
(
edit
)
Module:Message box
(
edit
)
Module:Protection banner
(
edit
)
Module:Template link general
(
edit
)