Content deleted Content added
Prepare the documentation for the ‘new’ modifier – currently commented out in the code |
m →cutting: emphasis |
||
(83 intermediate revisions by 4 users not shown) | |||
Line 5:
| above = '''About the latest changes'''
| text = See the '''[[Module:Params/ChangeLog|ChangeLog]]'''
| below = <small>Last update: {{#time:j xg Y|{{REVISIONTIMESTAMP:Module:Params}}}}</small><br /><small>[[Module:Params/testcases|Testcases]] · [[Module:Params/doc/examples|Examples]] · [[Module:Params/sandbox|Sandbox]]</small>
| textstyle = padding: .85em; text-align: center;
}}
Line 13:
The module offers elegant shortcuts to non variadic templates as well. Outside templates it has virtually no applications; hence, if you plan to make experiments, make sure to do them from within a template, or you will not be able to see much (you can use {{tl|Template sandbox}} for that). Under {{rel|Module:Params/testcases}} you can find helper templates that can be specifically used for testing the module's capabilities in flexible ways. Finally, under {{rel|Module:Params/doc/examples}} you can find some of the examples shown in this documentation page.
{{A note}} In case your template uses <syntaxhighlight lang="wikitext" inline>{{#invoke:params}}</syntaxhighlight>, please add {{tji|lua|Module:Params}} to its documentation page, so that if breaking changes will be introduced in the future the template will be easily traceable without performing <span class="plainlinks">[//en.wikipedia.org/w/index.php?search=insource%3A%2Finvoke%3Aparams%
Please, do not edit this module without having done extensive testing in the [[Module:Params/sandbox|module's sandbox]] first.
Line 26:
<syntaxhighlight lang="wikitext">{{#invoke:params|setting|i/p|<br />|: |list}}</syntaxhighlight>
and such template were called with the following
{{tj|example template|Beast of Bodmin: A large feline inhabiting Bodmin Moor
Line 63:
<syntaxhighlight lang="wikitext">{{#invoke:params|non-sequential|with_name_matching|^B|with_name_matching|n$|with_value_matching|feline|setting|h/p/i/f|<dl><dt>|</dt><dd>|</dd><dt>|</dd></dl>|list}}</syntaxhighlight>
The two modifiers <code>[[#sequential|sequential]]</code> and <code>[[#non-sequential|non-sequential]]</code> refer to a technical jargon used in wikitext: given a parameter list, the subgroup of sequential parameters is constituted by the largest group of consecutive
== Functions ==
Line 149:
This function does not take arguments.
The number that this function yields depends on the modifiers that precede it. For instance, in a template that is called with both named and unnamed
<syntaxhighlight lang="wikitext" inline>{{#invoke:params|count}}</syntaxhighlight>
Line 168:
| label2 = Not affected by | data2 = <code>[[#all_sorted|all_sorted]]</code>, <code>[[#reassorted|reassorted]]</code>
| header3 = See also
| data4 = <code>[[#combining_by_calling|combining_by_calling]]</code>, <code>[[#concat_and_invoke|concat_and_invoke]]</code>, <code>[[#concat_and_magic|concat_and_magic]]</code>, <code>{{mfl|template wrapper|wrap}}</code>
}}
; Brief
: ''Prepend positive
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|concat_and_call|template name|[prepend 1]|[prepend 2]|[...]|[prepend n]|[named item 1=value 1]|[...]|[named item n=value n]|[...]}}</syntaxhighlight>
This function comes in handy in case of [[Wikipedia:Wrapper templates|wrapper templates]]. For example, if our <syntaxhighlight lang="wikitext" inline>{{
<syntaxhighlight lang="wikitext">{{#invoke:params|concat_and_call|foobar|elbow|earth|room|7=classy|hello=not today}}</syntaxhighlight>
Line 182:
and were called with,
{{tj|
the following call to the <syntaxhighlight lang="wikitext" inline>{{foobar}}</syntaxhighlight> template would be performed:
Line 189:
|wind: spicy|hello: not today}}
By using the <code>[[#cutting|cutting]]</code> modifier it is possible to impose
<syntaxhighlight lang="wikitext">{{#invoke:params|cutting|3|0|concat_and_call|my template|{{{1|}}}|{{{2|}}}|hello world}}</syntaxhighlight>
If the
If no other argument besides the ''template name''
{{vpad|clear=none}}
Line 214:
; Brief
: ''Prepend positive
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|concat_and_invoke|module name|function name|[prepend 1]|[prepend 2]|[...]|[prepend n]|[named item 1=value 1]|[...]|[named item n=value n]|[...]}}</syntaxhighlight>
Line 237:
; Brief
: ''Prepend positive
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|concat_and_magic|parser function|[prepend 1]|[prepend 2]|[...]|[prepend n]|[named item 1=value 1]|[...]|[named item n=value n]|[...]}}</syntaxhighlight>
Line 254:
| title = Function <code>value_of</code> <span style="nowrap">({{module:params/doc/link to the code|value_of|code}})</span>
| label1 = Num. of arguments | data1 = 1
| label2 = Relevant [[#setting|
| label3 = Not affected by | data3 = <code>[[#all_sorted|all_sorted]]</code>, <code>[[#reassorted|reassorted]]</code>
| header4 = See also
| data5 = <code>[[#list_values|list_values]]</code>, <code>[[#coins|coins]]</code>, <code>[[#unique_coins|unique_coins]]</code>
}}
Line 289:
| titlestyle = font-weight:normal; font-size:100%;
| title = Function <code>list</code> <span style="nowrap">({{module:params/doc/link to the code|list|code}})</span>
| label1 = Num. of arguments | data1 =
| label2 = [[#
| label3 = Relevant [[#setting|
| header4 = See also
| data5 = <code>[[#list_values|list_values]]</code>
Line 319:
| titlestyle = font-weight:normal; font-size:100%;
| title = Function <code>list_values</code> <span style="nowrap">({{module:params/doc/link to the code|list_values|code}})</span>
| label1 = Num. of arguments | data1 =
| label2 = [[#
| label3 = Often preceeded by | data3 = <code>[[#sequential|sequential]]</code>
| label4 = Relevant [[#setting|
| header5 = See also
| data6 = <code>[[#list|list]]</code>, <code>[[#value_of|value_of]]</code>, <code>[[#coins|coins]]</code>, <code>[[#unique_coins|unique_coins]]</code>, {{mlx|separated entries|}}
}}
Line 343:
: '''Values of parameters passed:''' A giant owl-like creature; A large feline inhabiting Bodmin Moor; A sea serpent.
{{vpad|1.5em|clear=none}}
=== <code>coins</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Function <code>coins</code> <span style="nowrap">({{module:params/doc/link to the code|coins|code}})</span>
| label1 = Num. of arguments | data1 = ''Ad libitum''
| label2 = [[#all_sorted|Sortable]] | data2 = Yes
| label3 = Often preceeded by | data3 = <code>[[#sequential|sequential]]</code>, <code>[[#trimming_values|trimming_values]]</code>
| label4 = Relevant [[#setting|function-only variables]] | data4 = <code>h</code>, <code>i</code>, <code>l</code>, <code>f</code>, <code>n</code>
| header5 = See also
| data6 = <code>[[#unique_coins|unique_coins]]</code>, <code>[[#list|list]]</code>, <code>[[#value_of|value_of]]</code>
}}
; Brief
: ''Associate custom strings to possible parameter values and list the custom string when the associated value is present''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|coins|[first coin = value 1]|[second coin = value 2]|[...]|[last coin = value N]}}</syntaxhighlight>
This function is identical to the <code>[[#unique_coins|unique_coins]]</code> function, except that it allows the repetition of identical flags. See there for more information.
{{vpad|1.5em|clear=none}}
=== <code>unique_coins</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Function <code>unique_coins</code> <span style="nowrap">({{module:params/doc/link to the code|unique_coins|code}})</span>
| label1 = Num. of arguments | data1 = ''Ad libitum''
| label2 = [[#all_sorted|Sortable]] | data2 = Yes
| label3 = Often preceeded by | data3 = <code>[[#sequential|sequential]]</code>, <code>[[#trimming_values|trimming_values]]</code>
| label4 = Relevant [[#setting|function-only variables]] | data4 = <code>h</code>, <code>i</code>, <code>l</code>, <code>f</code>, <code>n</code>
| header5 = See also
| data6 = <code>[[#coins|coins]]</code>, <code>[[#list|list]]</code>, <code>[[#value_of|value_of]]</code>
}}
; Brief
: ''Associate custom strings to possible parameter values and list the custom string when the associated value is present, but not more than once''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|unique_coins|[first coin = value 1]|[second coin = value 2]|[...]|[last coin = value N]}}</syntaxhighlight>
This function is used to detect the existence of flag parameters. For this reason, it is often accompanied by the <code>[[#sequential|sequential]]</code> modifier (or, equivalently, by <code>...|[[#excluding_non-numeric_names|excluding_non-numeric_names]]|[[#clearing|clearing]]|...</code>). For a similar function that allows the repetition of identical flags, see the <code>[[#coins|coins]]</code> function.
A typical use case of this function is that of constructing [[URL]]s. For example, the following template named <syntaxhighlight lang="wikitext" inline>{{example template}}</syntaxhighlight> checks for the <code>html</code>, <code>xml</code>, <code>comments</code> and <code>removenowiki</code> flags in order to append respectively the following strings to the final URL: <code>&wpGenerateRawHtml=1</code>, <code>&wpGenerateXml=1</code>, <code>&wpRemoveComments=0</code>, <code>&wpRemoveNowiki=1</code>.
<syntaxhighlight lang="wikitext">{{#if:{{{input|}}}
| <span class="plainlinks">[{{fullurl:Special:ExpandTemplates|wpInput={{urlencode:{{{input}}}|QUERY}}{{#if:{{{title|}}}|&wpContextTitle={{urlencode|{{{title}}}|QUERY}}}}{{#invoke:params|excluding_non-numeric_names|clearing|sequential|trimming_values|unique_coins
| html = &wpGenerateRawHtml=1
| xml = &wpGenerateXml=1
| comments = &wpRemoveComments=0
| removenowiki = &wpRemoveNowiki=1
}}}} {{#if:{{{label|}}}|{{{label|}}}|Expand <code>{{{input}}}</code>}}]</span>
| {{Error|Error: The {{para|input}} parameter is missing.}}
}}</syntaxhighlight>
And so, when transcluded as,
<syntaxhighlight lang="wikitext">{{example template|comments|xml
| input = Hello world {<nowiki />{#time:r{{!}}now}<nowiki />}
}}</syntaxhighlight>
it will generate the following output:
: {{module:params/doc/examples/link to expanded template|comments|xml
| input = Hello world {<nowiki />{#time:r{{!}}now}<nowiki />}
}}
A copy of the example above is available at {{{{rel|Module:Params/doc/examples/link to expanded template}}}}.
If the <code>[[#setting|setting]]</code> modifier was not placed earlier, this function will not add delimiters, but will return an indistinct blob of text in which values are sticked to each other. A header (<code>h</code>), an iteration delimiter (<code>i</code>), a last iteration delimiter (<code>l</code>), a footer (<code>f</code>), and a fallback text (<code>n</code>) can be declared via <code>[[#setting|setting]]</code> – the string assigned to the key-value pair delimiter (<code>p</code>) will be ignored.
{{vpad|1.5em|clear=none}}
Line 351 ⟶ 421:
| title = Function <code>call_for_each</code> <span style="nowrap">({{module:params/doc/link to the code|call_for_each|code}})</span>
| label1 = Num. of arguments | data1 = ''Ad libitum''
| label2 = [[#
| label3 = Relevant [[#setting|
| header4 = See also
| data5 = <code>[[#call_for_each_value|call_for_each_value]]</code>, <code>[[#mapping_by_calling|mapping_by_calling]]</code>, <code>[[#invoke_for_each|invoke_for_each]]</code>, <code>[[#magic_for_each|magic_for_each]]</code>, <code>[[#call_for_each_group|call_for_each_group]]</code>, {{mlx|for loop|}}, {{tl2|for loop}}
Line 388 ⟶ 458:
| title = Function <code>invoke_for_each</code> <span style="nowrap">({{module:params/doc/link to the code|invoke_for_each|code}})</span>
| label1 = Num. of arguments | data1 = ''Ad libitum''
| label2 = [[#
| label3 = Relevant [[#setting|
| header4 = See also
| data5 = <code>[[#invoke_for_each_value|invoke_for_each_value]]</code>, <code>[[#mapping_by_invoking|mapping_by_invoking]]</code>, <code>[[#call_for_each|call_for_each]]</code>, <code>[[#magic_for_each|magic_for_each]]</code>
Line 422 ⟶ 492:
| title = Function <code>magic_for_each</code> <span style="nowrap">({{module:params/doc/link to the code|magic_for_each|code}})</span>
| label1 = Num. of arguments | data1 = ''Ad libitum''
| label2 = [[#
| label3 = Relevant [[#setting|
| header4 = See also
| data5 = <code>[[#magic_for_each_value|magic_for_each_value]]</code>, <code>[[#mapping_by_magic|mapping_by_magic]]</code>, <code>[[#call_for_each|call_for_each]]</code>, <code>[[#invoke_for_each|invoke_for_each]]</code>
Line 446 ⟶ 516:
| title = Function <code>call_for_each_value</code> <span style="nowrap">({{module:params/doc/link to the code|call_for_each_value|code}})</span>
| label1 = Num. of arguments | data1 = ''Ad libitum''
| label2 = [[#
| label3 = Often preceeded by | data3 = <code>[[#sequential|sequential]]</code>
| label4 = Relevant [[#setting|
| header5 = See also
| data6 = <code>[[#call_for_each|call_for_each]]</code>, <code>[[#mapping_by_calling|mapping_by_calling]]</code>, <code>[[#invoke_for_each_value|invoke_for_each_value]]</code>, <code>[[#magic_for_each_value|magic_for_each_value]]</code>, <code>[[#call_for_each_group|call_for_each_group]]</code>, {{mlx|for loop|}}, {{tl2|for loop}}
Line 481 ⟶ 551:
| title = Function <code>invoke_for_each_value</code> <span style="nowrap">({{module:params/doc/link to the code|invoke_for_each_value|code}})</span>
| label1 = Num. of arguments | data1 = ''Ad libitum''
| label2 = [[#
| label3 = Often preceeded by | data3 = <code>[[#sequential|sequential]]</code>
| label4 = Relevant [[#setting|
| header5 = See also
| data6 = <code>[[#call_for_each_value|call_for_each_value]]</code>, <code>[[#mapping_by_invoking|mapping_by_invoking]]</code>, <code>[[#invoke_for_each|invoke_for_each]]</code>, <code>[[#magic_for_each_value|magic_for_each_value]]</code>
Line 516 ⟶ 586:
| title = Function <code>magic_for_each_value</code> <span style="nowrap">({{module:params/doc/link to the code|magic_for_each_value|code}})</span>
| label1 = Num. of arguments | data1 = ''Ad libitum''
| label2 = [[#
| label3 = Often preceeded by | data3 = <code>[[#sequential|sequential]]</code>
| label4 = Relevant [[#setting|
| header5 = See also
| data6 = <code>[[#call_for_each_value|call_for_each_value]]</code>, <code>[[#mapping_by_magic|mapping_by_magic]]</code>, <code>[[#invoke_for_each_value|invoke_for_each_value]]</code>, <code>[[#magic_for_each|magic_for_each]]</code>
Line 552 ⟶ 622:
| label1 = Num. of arguments | data1 = ''Ad libitum''
| label2 = Often preceeded by | data2 = <code>[[#all_sorted|all_sorted]]</code>, <code>[[#reassorted|reassorted]]</code>
| label3 = [[#
| label4 = Relevant [[#setting|
| header5 = See also
| data6 = <code>[[#grouping_by_calling|grouping_by_calling]]</code>, <code>[[#call_for_each|call_for_each]]</code>, <code>[[#call_for_each_value|call_for_each_value]]</code>, {{mlx|for loop|}}, {{tl2|for loop}}
Line 559 ⟶ 629:
; Brief
: ''Call a custom template for each group of parameters that have the same
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|
}}</syntaxhighlight>
The custom template will be repeatedly called with the
All unnamed arguments that follow the ''template name'' in the invocation of this module will appear as sequential parameters in each call. Named arguments will be passed verbatim. Both named and unnamed arguments passed to this function will be given precedence in case of collisions.
A header (<code>h</code>), an iteration delimiter (<code>i</code>), a last iteration delimiter (<code>l</code>), a footer (<code>f</code>), and a fallback text (<code>n</code>) can be declared via the <code>[[#setting|setting]]</code> modifier – the string assigned to the key-value pair delimiter (<code>p</code>) will be ignored.
Line 626 ⟶ 696:
}}</syntaxhighlight>
'''The modifiers <code>[[#sequential|sequential]]</code>, <code>[[#non-sequential|non-sequential]]</code>, <code>[[#all_sorted|all_sorted]]</code> and <code>[[#reassorted|reassorted]]</code> will affect what groups of parameters will be iterated, not what parameters will be grouped.''' Before calling this function you will likely want to reduce the list of parameters via one of the <code>with_*_matching</code> group of modifiers (for instance <code>...|with_name_matching|.%-%d+$|or|[^%-]%d+$|call_for_each_group|...</code> leaves only the parameters in which both the prefix and the
{{vpad|clear=none}}
Line 662 ⟶ 732:
}}
See also {{{{rel|Module:Params/doc/examples/tablebox}}}} for
{{vpad|clear=none}}
Line 675 ⟶ 745:
| title = Function <code>for_each</code> <span style="nowrap">({{module:params/doc/link to the code|for_each|code}})</span>
| label1 = Num. of arguments | data1 = 1
| label2 = [[#
| label3 = Relevant [[#setting|
| header4 = See also
| data5 = <code>[[#list|list]]</code>, <code>[[#list_values|list_values]]</code>, {{mlx|for nowiki|}}, {{tl2|for nowiki}}, {{tl2|expand wikitext}}
}}
Line 690 ⟶ 760:
<syntaxhighlight lang="wikitext">{{#invoke:params|for_each|Arg name: $#, Arg value: $@}}</syntaxhighlight>
The text returned by this function is not expanded further (currently this module does not offer an <code>expand_for_each</code> function). If you need wikitext expansion, use either <code>[[#concat_and_call|concat_and_call]]</code> to propagate the incoming parameters altogether to the {{tl|for nowiki}} template
Example #1 (wikitext expanded via the {{tl|for nowiki}} template – suggested):
<syntaxhighlight lang="wikitext">{{#invoke:params|sequential|concat_and_call|for nowiki|<br />|<nowiki>Parameter value is “{{{1}}}”</nowiki>}}</syntaxhighlight>
Example #2 (wikitext expanded via the {{tl|expand wikitext}} template – less efficient but more flexible):
<syntaxhighlight lang="wikitext">{{#invoke:params|setting|i|<br />|mapping_by_calling|expand wikitext|names_and_values_as|2|3|
let|1|<nowiki>Parameter name is “{{{2}}}”, parameter value is “{{{3}}}”</nowiki>|
let|unstrip|yes|
list_values}}</syntaxhighlight>
{{vpad|clear=none}}
Line 778 ⟶ 857:
; Brief
: ''(IN FUNCTIONS ONLY, DOES NOT AFFECT MODIFIERS) When the time will come, all parameters will be dispatched sorted: first the
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|all_sorted|pipe function name}}</syntaxhighlight>
Line 790 ⟶ 869:
This modifier does not take arguments besides the name of the function that will follow.
Normally only sequential parameters are dispatched sorted, whereas non-sequential ones are dispatched randomly. The <code>all_sorted</code> modifier ensures that nothing is left out of ([[natural sort order|natural]]) order. Attention must be paid to the fact that parameters whose name is a negative number will appear first. To avoid this the <code>[[#squeezing|squeezing]]</code> modifier can be used.<ref>To be precise, the order will not be strictly alphabetical, because this would imply that a template called with the following parameters <syntaxhighlight lang="wikitext" inline>{{foobar|-4=you|9=wanna|.=me?|11=marry|-8=do}}</syntaxhighlight> would see them reordered as follows: <syntaxhighlight lang="wikitext" inline>{{foobar|-8=do|-4=you|.=me?|9=wanna|11=marry}}</syntaxhighlight> (with the dot in the middle between negative and positive numbers). To avoid this, '''numbers are always
The <code>all_sorted</code> modifier only affects the way parameters are shown, but has no effects on functions that do not iterate or cannot impose an order, such as:
Line 819 ⟶ 898:
; Brief
: ''(IN FUNCTIONS ONLY, DOES NOT AFFECT MODIFIERS) When the time will come, all parameters will be dispatched sorted: first non
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|reassorted|pipe function name}}</syntaxhighlight>
Line 931 ⟶ 1,010:
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#filling_the_gaps|filling_the_gaps]]</code>, <code>[[#sequential|sequential]]</code>, <code>[[#clearing|clearing]]</code>, <code>[[Module:TableTools#compressSparseArray|TableTools.compressSparseArray]]</code>
}}
; Brief
: ''Rearrange all parameters that have
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|squeezing|pipe function name}}</syntaxhighlight>
Line 943 ⟶ 1,022:
<syntaxhighlight lang="wikitext">{{#invoke:params|squeezing|sequential|setting|i/p|<br />|: |list}}</syntaxhighlight>
This modifier does not take arguments besides the name of the function that will follow. If you are a module writer, you might recognize some similarities between this function and <code>[[Module:TableTools#compressSparseArray|TableTools.compressSparseArray]]</code>.
The following three concatenations will lead to the same result of discarding all parameters with
# <syntaxhighlight lang="wikitext" inline>{{...|excluding_numeric_names|...}}</syntaxhighlight>
# <syntaxhighlight lang="wikitext" inline>{{...|with_name_not_matching|^%-?%d+$|...}}</syntaxhighlight>
# <syntaxhighlight lang="wikitext" inline>{{...|non-sequential|squeezing|...}}</syntaxhighlight>
# <syntaxhighlight lang="wikitext" inline>{{...|squeezing|non-sequential|...}}</syntaxhighlight>
The first solution is the most optimized one. Furthermore, in the last two solutions the numeric parameters are discarded just before the final function is invoked (sometimes this might be a wanted result).
{{vpad|1.5em|clear=none}}
Line 964 ⟶ 1,046:
; Brief
: ''Assign an empty string to all undefined
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|filling_the_gaps|pipe function name}}</syntaxhighlight>
Line 974 ⟶ 1,056:
This modifier does not take arguments besides the name of the function that will follow.
Note that when all
{| class="wikitable" style="margin-left: auto; margin-right: auto;"
|+
|-
! Before calling <code>filling_the_gaps</code>
Line 1,020 ⟶ 1,102:
; Brief
: ''Remove all
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|clearing|pipe function name}}</syntaxhighlight>
Line 1,026 ⟶ 1,108:
This modifier does not take arguments besides the name of the function that will follow.
Unlike <code>[[#sequential|sequential]]</code> – which affects only the way parameters are shown – this modifier actually removes all non-sequential
Example:
Line 1,032 ⟶ 1,114:
<syntaxhighlight lang="wikitext">{{#invoke:params|clearing|setting|i/p|<br />|: |list}}</syntaxhighlight>
If you want to remove also non-
<syntaxhighlight lang="wikitext">{{#invoke:params|clearing|
If you want instead to remove sequential parameters and leave the rest, use <syntaxhighlight lang="wikitext" inline>{{...|cutting|-1|1|...}}</syntaxhighlight>:
Line 1,050 ⟶ 1,132:
| label3 = Often accompanied by | data3 = <code>[[#sequential|sequential]]</code>
| header4 = See also
| data5 = <code>[[#sequential|sequential]]</code>, <code>[[#squeezing|squeezing]]</code>, <code>[[#filling_the_gaps|filling_the_gaps]]</code>, <code>[[#clearing|clearing]]</code>, <code>[[#cropping|cropping]]</code>, <code>[[#purging|purging]]</code>, <code>[[#backpurging|backpurging]]</code>, <code>[[#
}}
Line 1,064 ⟶ 1,146:
<syntaxhighlight lang="wikitext">{{#invoke:params|cutting|0|2|sequential|call_for_each_value|example template}}</syntaxhighlight>
If the absolute value of the sum of the two arguments (left and right cut) is greater than the number of ''sequential'' parameters available, the behavior will be the same as if the sum had been equal to the number of sequential parameters available, both when this is a positive value and when it is a negative value (with opposite results). After the desired sequential parameters have been discarded, '''all'''
In some cases it might be necessary to concatenate more than one invocation of the <code>cutting</code> modifier. For instance, the following code prints the last unnamed parameter passed, but only if at least two parameters were passed:
Line 1,082 ⟶ 1,164:
| label3 = Often accompanied by | data3 = <code>[[#sequential|sequential]]</code>
| header4 = See also
| data5 = <code>[[#sequential|sequential]]</code>, <code>[[#squeezing|squeezing]]</code>, <code>[[#filling_the_gaps|filling_the_gaps]]</code>, <code>[[#clearing|clearing]]</code>, <code>[[#cutting|cutting]]</code>, <code>[[#purging|purging]]</code>, <code>[[#backpurging|backpurging]]</code>, <code>[[#
}}
; Brief
: ''Remove zero or more parameters from the beginning and the end of the '''list of
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|cropping|left crop|right crop|pipe function name}}</syntaxhighlight>
This modifier is very similar to <code>[[#cutting|cutting]]</code>, but instead of removing arguments from the extremities of the parameters' ''sequence'', arguments will be removed counting from the first and the last
Example:
Line 1,110 ⟶ 1,192:
: 19: nineteen
If the absolute value of the sum of the two arguments (left and right crop) is greater than the difference between the largest and the lowest ''
{{vpad|1.5em|clear=none}}
Line 1,122 ⟶ 1,204:
| label3 = Often accompanied by | data3 = <code>[[#sequential|sequential]]</code>
| header4 = See also
| data5 = <code>[[#sequential|sequential]]</code>, <code>[[#squeezing|squeezing]]</code>, <code>[[#filling_the_gaps|filling_the_gaps]]</code>, <code>[[#clearing|clearing]]</code>, <code>[[#cutting|cutting]]</code>, <code>[[#cropping|cropping]]</code>, <code>[[#backpurging|backpurging]]</code>, <code>[[#
}}
; Brief
: ''Remove zero or more parameters from any point of the list of
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|purging|start offset|length|pipe function name}}</syntaxhighlight>
The first argument indicates at which point in the parameter list the removal must begin, the second argument indicates how many parameters must be discarded among it and what lies ''on the right side''. If the second argument contains zero or a negative number its absolute value indicates what must be left ''at the end of the right side'' of the list of
Example #1 (purge the first parameter):
<syntaxhighlight lang="wikitext">{{#invoke:params|purging|1|1|call_for_each_value|example template}}</syntaxhighlight>
Example #2 (purge the second, third, and four parameters):
<syntaxhighlight lang="wikitext">{{#invoke:params|purging|2|
{{vpad|1.5em|clear=none}}
Line 1,146 ⟶ 1,232:
| label3 = Often accompanied by | data3 = <code>[[#sequential|sequential]]</code>
| header4 = See also
| data5 = <code>[[#sequential|sequential]]</code>, <code>[[#squeezing|squeezing]]</code>, <code>[[#filling_the_gaps|filling_the_gaps]]</code>, <code>[[#clearing|clearing]]</code>, <code>[[#cutting|cutting]]</code>, <code>[[#cropping|cropping]]</code>, <code>[[#purging|purging]]</code>, <code>[[#
}}
; Brief
: ''Remove zero or more parameters from any point of the list of
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|backpurging|start offset|length|pipe function name}}</syntaxhighlight>
The first argument indicates at which point in the parameter list the removal must begin, the second argument indicates how many parameters must be discarded among it and what lies ''on the left side''. If the second argument contains zero or a negative number its absolute value indicates what must be left ''at the end of the left side'' of the list of
Example:
Line 1,160 ⟶ 1,246:
<syntaxhighlight lang="wikitext">{{#invoke:params|backpurging|3|1|call_for_each_value|example template}}</syntaxhighlight>
The following code removes all parameters with negative and zero
<syntaxhighlight lang="wikitext">{{#invoke:params|backpurging|0|0|for_each|[$#: $@]}}</syntaxhighlight>
Line 1,166 ⟶ 1,252:
{{vpad|1.5em|clear=none}}
=== <code>
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| label3 = Often accompanied by | data3 = <code>[[#sequential|sequential]]</code>
| header4 = See also
| data5 = <code>[[#sequential|sequential]]</code>, <code>[[#squeezing|squeezing]]</code>, <code>[[#filling_the_gaps|filling_the_gaps]]</code>, <code>[[#clearing|clearing]]</code>, <code>[[#cutting|cutting]]</code>, <code>[[#cropping|cropping]]</code>, <code>[[#purging|purging]]</code>, <code>[[#backpurging|backpurging]]</code><!--, <code>[[#
}}
; Brief
: ''Reverse the order of all
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|
This modifier does not take arguments besides the name of the function that will follow.
Line 1,186 ⟶ 1,272:
Example:
<syntaxhighlight lang="wikitext">{{#invoke:params|
{{A note}} If negative parameters are present this function becomes non-invertible. This means that <syntaxhighlight lang="wikitext" inline>{{#invoke:params|reversing_numeric_names|reversing_numeric_names|...}}</syntaxhighlight> will not restore the original parameter names, but will shift all numeric parameters so that what formerly was the smallest parameter name will now become {{para|1}}.
<!--
{{vpad|1.5em|clear=none}}
=== <code>
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| label3 = Often accompanied by | data3 = <code>[[#sequential|sequential]]</code>
| header4 = See also
| data5 = <code>[[#sequential|sequential]]</code>, <code>[[#squeezing|squeezing]]</code>, <code>[[#filling_the_gaps|filling_the_gaps]]</code>, <code>[[#clearing|clearing]]</code>, <code>[[#cutting|cutting]]</code>, <code>[[#cropping|cropping]]</code>, <code>[[#purging|purging]]</code>, <code>[[#backpurging|backpurging]]</code>, <code>[[#
}}
; Brief
: ''Reverse the order of all
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|
This modifier does not take arguments besides the name of the function that will follow.
This modifier reverses the order of
Example:
<syntaxhighlight lang="wikitext">{{#invoke:params|
{{vpad|1.5em|clear=none}}
=== <code>
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| label3 = Often accompanied by | data3 = <code>[[#sequential|sequential]]</code>
| header4 = See also
| data5 = <code>[[#sequential|sequential]]</code>, <code>[[#squeezing|squeezing]]</code>, <code>[[#filling_the_gaps|filling_the_gaps]]</code>, <code>[[#clearing|clearing]]</code>, <code>[[#cutting|cutting]]</code>, <code>[[#cropping|cropping]]</code>, <code>[[#purging|purging]]</code>, <code>[[#backpurging|backpurging]]</code>, <code>[[#
}}
; Brief
: ''Reverse the order of all
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|
This modifier does not take arguments besides the name of the function that will follow.
This modifier reverses the order of
Example:
<syntaxhighlight lang="wikitext">{{#invoke:params|
{{vpad|1.5em|clear=none}}
=== <code>
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| label3 = Often accompanied by | data3 = <code>[[#sequential|sequential]]</code>
| header4 = See also
| data5 = <code>[[#sequential|sequential]]</code>, <code>[[#squeezing|squeezing]]</code>, <code>[[#filling_the_gaps|filling_the_gaps]]</code>, <code>[[#clearing|clearing]]</code>, <code>[[#cutting|cutting]]</code>, <code>[[#cropping|cropping]]</code>, <code>[[#purging|purging]]</code>, <code>[[#backpurging|backpurging]]</code>, <code>[[#
}}
; Brief
: ''Swap the lowest
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|
This modifier does not take arguments besides the name of the function that will follow.
Line 1,262 ⟶ 1,350:
Example:
<syntaxhighlight lang="wikitext">{{#invoke:params|
-->
{{vpad|1.5em|clear=none}}
Line 1,274 ⟶ 1,362:
| label3 = Often accompanied by | data3 = <code>[[#sequential|sequential]]</code>
| header4 = See also
| data5 = <code>[[#sequential|sequential]]</code>, <code>[[#squeezing|squeezing]]</code>, <code>[[#filling_the_gaps|filling_the_gaps]]</code>, <code>[[#clearing|clearing]]</code>, <code>[[#cutting|cutting]]</code>, <code>[[#cropping|cropping]]</code>, <code>[[#purging|purging]]</code>, <code>[[#backpurging|backpurging]]</code>, <code>[[#
}}
Line 1,303 ⟶ 1,391:
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#imposing|imposing]]</code>, <code>[[#providing|providing]]</code>, <code>[[#sequential|sequential]]</code>, <code>[[#squeezing|squeezing]]</code>, <code>[[#filling_the_gaps|filling_the_gaps]]</code>, <code>[[#clearing|clearing]]</code>, <code>[[#cutting|cutting]]</code>, <code>[[#cropping|cropping]]</code>, <code>[[#purging|purging]]</code>, <code>[[#backpurging|backpurging]]</code>, <code>[[#
}}
; Brief
: ''Add one or more
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|inserting|position|how many|...|pipe function name}}</syntaxhighlight>
Line 1,314 ⟶ 1,402:
<syntaxhighlight lang="wikitext">{{#invoke:params|inserting|1|2|hello|world|for_each|[$#: $@]}}</syntaxhighlight>
Currently, appending parameters after the last numeric parameter requires some workaround. The following example will add three new parameters and list all parameters:
<syntaxhighlight lang="wikitext">{{#invoke:params|
all_sorted|
entering_substack|
backpurging|0|0|
detaching_substack|
reversing_numeric_names|
inserting|1|3|added parameter 3|added parameter 2|added parameter 1|
reversing_numeric_names|
merging_substack|
for_each|[$#:$@]}}</syntaxhighlight>
Similarly, the following workaround will append three parameters at the end of the sequence:
<syntaxhighlight lang="wikitext">{{#invoke:params|
all_sorted|
entering_substack|
clearing|
detaching_substack|
reversing_numeric_names|
inserting|1|3|added parameter 3|added parameter 2|added parameter 1|
reversing_numeric_names|
leaving_substack|
inserting|1|3||||
flushing|
for_each|[$#:$@]}}</syntaxhighlight>
{{vpad|clear=none}}
{{A note}} The values of the parameters inserted will not be trimmed of their leading and trailing spaces. The first two
-->
{{vpad|1.5em|clear=none}}
Line 1,382 ⟶ 1,498:
; Brief
: ''Discard one or more
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|discarding|name|[how many]|pipe function name}}</syntaxhighlight>
If, and only if, the name of the parameter is
Example #1 (discard the parameter named {{para|hello}}):
Line 1,419 ⟶ 1,535:
* {{ml|TemplatePar|valid}}
When used to discard single parameters, this modifier is equivalent to writing <code>...|[[
{{A note}} All arguments passed to this modifier and the <code>discarding</code> modifier name itself will be trimmed of their surrounding spaces.
{{vpad|1.5em|clear=none}}
=== <code>excluding_non-numeric_names</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>excluding_non-numeric_names</code> <span style="nowrap">({{module:params/doc/link to the code|excluding_non-numeric_names|code}})</span>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#excluding_non-numeric_names|excluding_non-numeric_names]]</code>, <code>[[#with_name_matching|with_name_matching]]</code>, <code>[[#with_name_not_matching|with_name_not_matching]]</code>, <code>[[#clearing|clearing]]</code>
}}
; Brief
: ''Discard all non-numeric parameters''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|excluding_non-numeric_names|pipe function name}}</syntaxhighlight>
This modifier is only syntax sugar for <code>...|with_name_matching|^%-?%d+$|...</code> (but using a slighly faster optimization). For the inverse modifier, see <code>[[#excluding_numeric_names|excluding_numeric_names]]</code>. If you want to remove also non-sequential parameters, add the <code>[[#clearing|clearing]]</code> modifier to the pipeline (<code>...|excluding_non-numeric_names|clearing|...</code>).
{{vpad|1.5em|clear=none}}
=== <code>excluding_numeric_names</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>excluding_numeric_names</code> <span style="nowrap">({{module:params/doc/link to the code|excluding_numeric_names|code}})</span>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#excluding_non-numeric_names|excluding_non-numeric_names]]</code>, <code>[[#with_name_matching|with_name_matching]]</code>, <code>[[#with_name_not_matching|with_name_not_matching]]</code>
}}
; Brief
: ''Discard all numeric parameters (not only the sequential ones)''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|excluding_numeric_names|pipe function name}}</syntaxhighlight>
This modifier is only syntax sugar for <code>...|with_name_not_matching|^%-?%d+$|...</code> (but using a slighly faster optimization). For the inverse modifier, see <code>[[#excluding_non-numeric_names|excluding_non-numeric_names]]</code>.
{{vpad|1.5em|clear=none}}
Line 1,432 ⟶ 1,586:
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#excluding_numeric_names|excluding_numeric_names]]</code>, <code>[[#excluding_non-numeric_names|excluding_non-numeric_names]]</code>, <code>[[#with_name_not_matching|with_name_not_matching]]</code>, <code>[[#with_value_matching|with_value_matching]]</code>, <code>[[#with_value_not_matching|with_value_not_matching]]</code>
}}
Line 1,501 ⟶ 1,655:
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#excluding_numeric_names|excluding_numeric_names]]</code>, <code>[[#excluding_non-numeric_names|excluding_non-numeric_names]]</code>,<code>[[#with_name_matching|with_name_matching]]</code>, <code>[[#with_value_matching|with_value_matching]]</code>, <code>[[#with_value_not_matching|with_value_not_matching]]</code>
}}
Line 1,529 ⟶ 1,683:
{{vpad|clear=none}}
{{N.b.}} For the sake of efficiency, please don't use this modifier with the <code>strict</code> flag unless accompanied by <code>or</code>, use <code>[[#discarding|discarding]]</code> instead!
{{A note}} The ''target'' arguments passed to this modifier will not be trimmed of their leading and trailing spaces. The <code>or</code>, <code>plain</code>, <code>strict</code> and <code>pattern</code> keywords, and the <code>with_name_not_matching</code> modifier name itself, however, will be trimmed of their surrounding spaces.
Line 1,624 ⟶ 1,778:
Order affects also performance, and how many values will be trimmed of their leading and trailing spaces will depend on where <code>trimming_values</code> is placed. For instance, if a template were invoked with 50 parameters and its code contained <syntaxhighlight lang="wikitext" inline>{{#invoke:params|trimming_values|cutting|-1|0|list}}</syntaxhighlight>, first all its values would be trimmed of leading and trailing blank spaces and then its first 49 parameters would be discarded. On the other hand, writing <syntaxhighlight lang="wikitext" inline>{{#invoke:params|cutting|-1|0|trimming_values|list}}</syntaxhighlight> would first discard 49 parameters and then trim the only value left, resulting in a more efficient code. As a general rule, placing <code>trimming_values</code> as the last modifier is usually the best choice.
In most cases placing <code>trimming_values</code> together with <code>non-sequential</code> will result in an empty call with no effects, because non-sequential parameters are normally stripped of their leading and trailing spaces by default – this however depends on the caller, and if the current template is being called by a module it is in theory possible in specific conditions for named parameters to retain their leading and trailing spaces (namely in non-sequential
Using <code>trimming_values</code> makes this module behave like many Wikipedia modules behave. For example, if we wanted to emulate {{ml|Separated entries|main}}, writing
Line 1,643 ⟶ 1,797:
The {{{{rel|Module:Params/doc/examples/trim and call}}}} example template shows how to call any arbitrary template trimming all parameters beforehand.
{{vpad|1.5em|clear=none}}
=== <code>converting_values_to_lowercase</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>converting_values_to_lowercase</code> <span style="nowrap">({{module:params/doc/link to the code|converting_values_to_lowercase|code}})</span>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#converting_values_to_uppercase|converting_values_to_uppercase]]</code>, <code>[[#converting_names_to_lowercase|converting_names_to_lowercase]]</code>, <code>[[#converting_names_to_uppercase|converting_names_to_uppercase]]</code>, <code>[[#mapping_by_replacing|mapping_by_replacing]]</code>, <code>[[#renaming_by_replacing|renaming_by_replacing]]</code>
}}
; Brief
: ''Convert all parameter values to lower case''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|converting_values_to_lowercase|pipe function name}}</syntaxhighlight>
This modifier does not take arguments besides the name of the function that will follow.
This modifier converts all parameter values to lower [[Letter case|case]]. It is identical to writing <code>...|[[#mapping_by_magic|mapping_by_magic]]|[[:mw:Help:Magic words#lc|lc]]|...</code>, but without the burden of calling a parser function.
{{vpad|1.5em|clear=none}}
=== <code>converting_values_to_uppercase</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>converting_values_to_uppercase</code> <span style="nowrap">({{module:params/doc/link to the code|converting_values_to_uppercase|code}})</span>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#converting_values_to_lowercase|converting_values_to_lowercase]]</code>, <code>[[#converting_names_to_lowercase|converting_names_to_lowercase]]</code>, <code>[[#converting_names_to_uppercase|converting_names_to_uppercase]]</code>, <code>[[#mapping_by_replacing|mapping_by_replacing]]</code>, <code>[[#renaming_by_replacing|renaming_by_replacing]]</code>
}}
; Brief
: ''Convert all parameter values to upper case''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|converting_values_to_uppercase|pipe function name}}</syntaxhighlight>
This modifier does not take arguments besides the name of the function that will follow.
This modifier converts all parameter values to upper [[Letter case|case]]. It is identical to writing <code>...|[[#mapping_by_magic|mapping_by_magic]]|[[:mw:Help:Magic words#uc|uc]]|...</code>, but without the burden of calling a parser function.
{{vpad|1.5em|clear=none}}
Line 1,653 ⟶ 1,849:
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#converting_values_to_lowercase|converting_values_to_lowercase]]</code>, <code>[[#converting_values_to_uppercase|converting_values_to_uppercase]]</code>, <code>[[#call_for_each|call_for_each]]</code>, <code>[[#call_for_each_value|call_for_each_value]]</code>, <code>[[#mapping_by_invoking|mapping_by_invoking]]</code>, <code>[[#mapping_by_magic|mapping_by_magic]]</code>, <code>[[#mapping_by_replacing|mapping_by_replacing]]</code>, <code>[[#converting_names_to_lowercase|converting_names_to_lowercase]]</code>, <code>[[#converting_names_to_uppercase|converting_names_to_uppercase]]</code>, <code>[[#renaming_by_calling|renaming_by_calling]]</code>, <code>[[#renaming_by_invoking|renaming_by_invoking]]</code>, <code>[[#renaming_by_magic|renaming_by_magic]]</code>, <code>[[#renaming_by_replacing|renaming_by_replacing]]</code>, <code>[[#grouping_by_calling|grouping_by_calling]]</code>
}}
Line 1,667 ⟶ 1,863:
If the ''call style flag'' or (if omitted) the ''template name'' is followed by one or more groups of three arguments led by the <code>let</code> keyword (i.e. <code>let|name|value</code>), these will be passed to the mapping template.
If the last group of three arguments or (if omitted) the ''call style flag'' or (if omitted) the ''template name'' is followed by a number, this will be parsed as the amount of positional parameters to add. These will always follow the current parameter's name and/or value if any of the latter
In case of collisions, the parameters assigned via the <code>let</code> keyword will be given precedence over everything else.
Line 1,739 ⟶ 1,935:
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#converting_values_to_lowercase|converting_values_to_lowercase]]</code>, <code>[[#converting_values_to_uppercase|converting_values_to_uppercase]]</code>, <code>[[#invoke_for_each|invoke_for_each]]</code>, <code>[[#invoke_for_each_value|invoke_for_each_value]]</code>, <code>[[#mapping_by_calling|mapping_by_calling]]</code>, <code>[[#mapping_by_magic|mapping_by_magic]]</code>, <code>[[#mapping_by_replacing|mapping_by_replacing]]</code>, <code>[[#converting_names_to_lowercase|converting_names_to_lowercase]]</code>, <code>[[#converting_names_to_uppercase|converting_names_to_uppercase]]</code>, <code>[[#renaming_by_calling|renaming_by_calling]]</code>, <code>[[#renaming_by_invoking|renaming_by_invoking]]</code>, <code>[[#renaming_by_magic|renaming_by_magic]]</code>, <code>[[#renaming_by_replacing|renaming_by_replacing]]</code>, <code>[[#grouping_by_calling|grouping_by_calling]]</code>
}}
Line 1,753 ⟶ 1,949:
If the ''call style flag'' or (if omitted) the ''function name'' is followed by one or more groups of three arguments led by the <code>let</code> keyword (i.e. <code>let|name|value</code>), these will be passed to the mapping module function.
If the last group of three arguments or (if omitted) the ''call style flag'' or (if omitted) the ''function name'' is followed by a number, this will be parsed as the amount of positional parameters to add. These will always follow the current parameter's name and/or value if any of the latter
In case of collisions, the arguments assigned via the <code>let</code> keyword will be given precedence over everything else.
Line 1,782 ⟶ 1,978:
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#converting_values_to_lowercase|converting_values_to_lowercase]]</code>, <code>[[#converting_values_to_uppercase|converting_values_to_uppercase]]</code>, <code>[[#magic_for_each|magic_for_each]]</code>, <code>[[#magic_for_each_value|magic_for_each_value]]</code>, <code>[[#mapping_by_calling|mapping_by_calling]]</code>, <code>[[#mapping_by_invoking|mapping_by_invoking]]</code>, <code>[[#mapping_by_replacing|mapping_by_replacing]]</code>, <code>[[#converting_names_to_lowercase|converting_names_to_lowercase]]</code>, <code>[[#converting_names_to_uppercase|converting_names_to_uppercase]]</code>, <code>[[#renaming_by_calling|renaming_by_calling]]</code>, <code>[[#renaming_by_invoking|renaming_by_invoking]]</code>, <code>[[#renaming_by_magic|renaming_by_magic]]</code>, <code>[[#renaming_by_replacing|renaming_by_replacing]]</code>, <code>[[#grouping_by_calling|grouping_by_calling]]</code>
}}
Line 1,796 ⟶ 1,992:
If the ''call style flag'' or (if omitted) the ''template name'' is followed by one or more groups of three arguments led by the <code>let</code> keyword (i.e. <code>let|name|value</code>), these will be passed to the parser function.
If the last group of three arguments or (if omitted) the ''call style flag'' or (if omitted) the ''template name'' is followed by a number, this will be parsed as the amount of positional arguments to add. These will always follow the current parameter's name and/or value if any of the latter
In case of collisions, the arguments assigned via the <code>let</code> keyword will be given precedence over everything else.
Line 1,825 ⟶ 2,021:
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#mapping_by_mixing|mapping_by_mixing]]</code>, <code>[[#converting_values_to_lowercase|converting_values_to_lowercase]]</code>, <code>[[#converting_values_to_uppercase|converting_values_to_uppercase]]</code>, <code>[[#mapping_by_calling|mapping_by_calling]]</code>, <code>[[#mapping_by_invoking|mapping_by_invoking]]</code>, <code>[[#mapping_by_magic|mapping_by_magic]]</code>, <code>[[#converting_names_to_lowercase|converting_names_to_lowercase]]</code>, <code>[[#converting_names_to_uppercase|converting_names_to_uppercase]]</code>, <code>[[#renaming_by_calling|renaming_by_calling]]</code>, <code>[[#renaming_by_invoking|renaming_by_invoking]]</code>, <code>[[#renaming_by_magic|renaming_by_magic]]</code>, <code>[[#renaming_by_replacing|renaming_by_replacing]]</code>, <code>[[#renaming_by_mixing|renaming_by_mixing]]</code>, <code>[[#grouping_by_calling|grouping_by_calling]]</code>, <code>[[#mixing_names_and_values]]</code>
}}
Line 1,839 ⟶ 2,035:
The ''count'' argument prescribes how many substitutions will be performed at most. If blank or omitted, all matches found will be substituted.
This modifier uses <code>[[:mw:Extension:Scribunto/Lua reference manual#string.gsub|string.gsub()]]</code> for performance reasons; if you need to use <code>[[:mw:Extension:Scribunto/Lua reference manual#mw.ustring.gsub|mw.ustring.gsub()]]</code> instead, you will need to invoke the <code>[[Module:String#replace|replace]]</code> function from [[Module:String]] via <code>...|[[#mapping_by_invoking|mapping_by_invoking]]|[[Module:String|string]]|[[Module:String#replace|replace]]|...</code>.
The following table shows examples of equivalent instructions. Please be aware that invoking <code>[[:mw:Extension:Scribunto/Lua reference manual#mw.ustring.gsub|mw.ustring.gsub()]]</code> can be much slower.
{| class="wikitable"
|-
! <code>[[:mw:Extension:Scribunto/Lua reference manual#string.gsub|string.gsub()]]</code>
! <code>[[:mw:Extension:Scribunto/Lua reference manual#mw.ustring.gsub|mw.ustring.gsub()]]</code> (via [[Module:String]])
|-
| <code>...|mapping_by_replacing|target|replace|...</code>
| <code>...|mapping_by_invoking|string|replace|4|target|replace||false|...</code>
|-
| <code>...|mapping_by_replacing|target|replace|count|...</code>
| <code>...|mapping_by_invoking|string|replace|4|target|replace|count|false|...</code>
|-
| <code>...|mapping_by_replacing|target|replace|plain|...</code>
| <code>...|mapping_by_invoking|string|replace|2|target|replace|...</code><br />or, equivalently,<br /><code>...|mapping_by_invoking|string|replace|4|target|replace||true|...</code>
|-
| <code>...|mapping_by_replacing|target|replace|count|plain|...</code>
| <code>...|mapping_by_invoking|string|replace|3|target|replace|count|...</code><br />or, equivalently,<br /><code>...|mapping_by_invoking|string|replace|4|target|replace|count|true|...</code>
|}
There is not a corresponding translation for the <code>strict</code> flag in [[Module:String]]. However, as it goes with the <code>plain</code> flag, in that case you won't need <code>[[:mw:Extension:Scribunto/Lua reference manual#mw.ustring.gsub|mw.ustring.gsub()]]</code> in the first place.
For example,
<syntaxhighlight lang="wikitext">...|mapping_by_renaming|foo|bar|1|...</syntaxhighlight>
will be equivalent to writing
<syntaxhighlight lang="wikitext">...|mapping_by_invoking|string|replace|4|foo|bar|1|
The first syntax, however, will be less computationally expensive.
At {{{{rel|Module:Params/doc/examples/informal tablebox}}}} you can find an example on how to exploit this function to create “informal” [[Template:Infobox|infoboxes]].
Line 1,854 ⟶ 2,074:
{{A note}} The ''target'' and ''replace'' arguments passed to this modifier will not be trimmed of their leading and trailing spaces. The <code>or</code>, <code>plain</code>, <code>strict</code> and <code>pattern</code> keywords, the ''count'' argument, and the <code>mapping_by_replacing</code> modifier name itself, however, will be trimmed of their surrounding spaces.
{{vpad|1.5em|clear=none}}
=== <code>mapping_by_mixing</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>mapping_by_mixing</code> <span style="nowrap">({{module:params/doc/link to the code|mapping_by_mixing|code}})</span>
| label1 = Num. of arguments | data1 = 1
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <!--<code>[[#mapping_to_names|mapping_to_names]]</code>, --><code>[[#converting_values_to_lowercase|converting_values_to_lowercase]]</code>, <code>[[#converting_values_to_uppercase|converting_values_to_uppercase]]</code>, <code>[[#mapping_by_calling|mapping_by_calling]]</code>, <code>[[#mapping_by_invoking|mapping_by_invoking]]</code>, <code>[[#mapping_by_magic|mapping_by_magic]]</code>, <code>[[#converting_names_to_lowercase|converting_names_to_lowercase]]</code>, <code>[[#converting_names_to_uppercase|converting_names_to_uppercase]]</code>, <code>[[#renaming_by_calling|renaming_by_calling]]</code>, <code>[[#renaming_by_invoking|renaming_by_invoking]]</code>, <code>[[#renaming_by_magic|renaming_by_magic]]</code>, <code>[[#renaming_by_replacing|renaming_by_replacing]]</code>, <code>[[#renaming_by_mixing|renaming_by_mixing]]</code><!--, <code>[[#renaming_to_values|renaming_to_values]]</code>-->, <code>[[#grouping_by_calling|grouping_by_calling]]</code>, <code>[[#mixing_names_and_values|mixing_names_and_values]]</code><!--, <code>[[#swapping_names_and_values|swapping_names_and_values]]</code>-->
}}
; Brief
: ''[[Map (higher-order function)|Map]] all parameter values replacing their current values with the expansion of a custom string containing the <code>$#</code> and <code>$@</code> placeholders''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|mapping_by_mixing|mixing string|pipe function name}}</syntaxhighlight>
This modifier (temporarily) changes the content of the parameters the current template is being called with, replacing each of them with the expansion of a custom string that expects the same syntax as the <code>[[#for_each|for_each]]</code> function.
For instance, the following code will wrap all parameter values in quotes
<syntaxhighlight lang="wikitext">...|mapping_by_mixing|“$@”|...</syntaxhighlight>
whereas the following code will replace all values with the string <code>[NAME::VALUE]</code>, where <code>NAME</code> and <code>VALUE</code> are each parameter's name and value:
<syntaxhighlight lang="wikitext">...|mapping_by_mixing|[$#::$@]|...</syntaxhighlight>
<!--
If you need to map all parameters exactly matching their names, please use <code>[[#mapping_to_names|mapping_to_names]]</code>.
-->
{{vpad|clear=none}}
{{A note}} Both the ''mixing string'' argument and the <code>mapping_by_mixing</code> modifier name itself will be trimmed of their surrounding spaces.
{{vpad|1.5em|clear=none}}
<!--
=== <code>mapping_to_names</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>mapping_to_names</code> <span style="nowrap">({{module:params/doc/link to the code|mapping_to_names|code}})</span>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#mapping_by_mixing|mapping_by_mixing]]</code>, <code>[[#converting_values_to_lowercase|converting_values_to_lowercase]]</code>, <code>[[#converting_values_to_uppercase|converting_values_to_uppercase]]</code>, <code>[[#mapping_by_calling|mapping_by_calling]]</code>, <code>[[#mapping_by_invoking|mapping_by_invoking]]</code>, <code>[[#mapping_by_magic|mapping_by_magic]]</code>, <code>[[#converting_names_to_lowercase|converting_names_to_lowercase]]</code>, <code>[[#converting_names_to_uppercase|converting_names_to_uppercase]]</code>, <code>[[#renaming_by_calling|renaming_by_calling]]</code>, <code>[[#renaming_by_invoking|renaming_by_invoking]]</code>, <code>[[#renaming_by_magic|renaming_by_magic]]</code>, <code>[[#renaming_by_replacing|renaming_by_replacing]]</code>, <code>[[#renaming_by_mixing|renaming_by_mixing]]</code>, <code>[[#renaming_to_values|renaming_to_values]]</code>, <code>[[#grouping_by_calling|grouping_by_calling]]</code>, <code>[[#mixing_names_and_values|mixing_names_and_values]]</code>, <code>[[#swapping_names_and_values|swapping_names_and_values]]</code>
}}
; Brief
: ''[[Map (higher-order function)|Map]] all parameter values, replacing the latter with their parameter name''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|mapping_to_names|pipe function name}}</syntaxhighlight>
This modifier does not take arguments besides the name of the function that will follow.
After calling this modifier, all parameters will have their value identical to their name. It is a shortcut for <code>...|[[#mapping_by_mixing|mapping_by_mixing]]|$#|...</code>, but slightly more efficient.
{{vpad|clear=none}}
{{A note}} The <code>mapping_to_names</code> modifier name will be trimmed of its surrounding spaces.
{{vpad|1.5em|clear=none}}
-->
=== <code>converting_names_to_lowercase</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>converting_names_to_lowercase</code> <span style="nowrap">({{module:params/doc/link to the code|converting_names_to_lowercase|code}})</span>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#converting_values_to_lowercase|converting_values_to_lowercase]]</code>, <code>[[#converting_values_to_uppercase|converting_values_to_uppercase]]</code>, <code>[[#converting_names_to_uppercase|converting_names_to_uppercase]]</code>, <code>[[#mapping_by_replacing|mapping_by_replacing]]</code>, <code>[[#renaming_by_replacing|renaming_by_replacing]]</code>
}}
; Brief
: ''Convert all parameter names to lower case''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|converting_names_to_lowercase|pipe function name}}</syntaxhighlight>
This modifier does not take arguments besides the name of the function that will follow.
This modifier converts all parameter names to lower [[Letter case|case]]. It is identical to writing <code>...|[[#renaming_by_magic|renaming_by_magic]]|[[:mw:Help:Magic words#lc|lc]]|...</code>, but without the burden of calling a parser function.
{{A note}} In case of collisions between identical names, only one parameter, randomly chosen, will be left for a given name.
{{vpad|1.5em|clear=none}}
=== <code>converting_names_to_uppercase</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>converting_names_to_uppercase</code> <span style="nowrap">({{module:params/doc/link to the code|converting_names_to_uppercase|code}})</span>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#converting_values_to_lowercase|converting_values_to_lowercase]]</code>, <code>[[#converting_values_to_uppercase|converting_values_to_uppercase]]</code>, <code>[[#converting_names_to_lowercase|converting_names_to_lowercase]]</code>, <code>[[#mapping_by_replacing|mapping_by_replacing]]</code>, <code>[[#renaming_by_replacing|renaming_by_replacing]]</code>
}}
; Brief
: ''Convert all parameter names to upper case''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|converting_names_to_uppercase|pipe function name}}</syntaxhighlight>
This modifier does not take arguments besides the name of the function that will follow.
This modifier converts all parameter names to upper [[Letter case|case]]. It is identical to writing <code>...|[[#renaming_by_magic|renaming_by_magic]]|[[:mw:Help:Magic words#uc|uc]]|...</code>, but without the burden of calling a parser function.
{{A note}} In case of collisions between identical names, only one parameter, randomly chosen, will be left for a given name.
{{vpad|1.5em|clear=none}}
Line 1,864 ⟶ 2,189:
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#converting_values_to_lowercase|converting_values_to_lowercase]]</code>, <code>[[#converting_values_to_uppercase|converting_values_to_uppercase]]</code>, <code>[[#mapping_by_calling|mapping_by_calling]]</code>, <code>[[#mapping_by_invoking|mapping_by_invoking]]</code>, <code>[[#mapping_by_magic|mapping_by_magic]]</code>, <code>[[#mapping_by_replacing|mapping_by_replacing]]</code>, <code>[[#converting_names_to_lowercase|converting_names_to_lowercase]]</code>, <code>[[#converting_names_to_uppercase|converting_names_to_uppercase]]</code>, <code>[[#renaming_by_invoking|renaming_by_invoking]]</code>, <code>[[#renaming_by_magic|renaming_by_magic]]</code>, <code>[[#renaming_by_replacing|renaming_by_replacing]]</code>, <code>[[#grouping_by_calling|grouping_by_calling]]</code>
}}
Line 1,881 ⟶ 2,206:
<syntaxhighlight lang="wikitext">{{#invoke:params|setting|h/i/p/f|[|][|: |]|renaming_by_calling|2x|1|-|list}}</syntaxhighlight>
The following example calls the {{Tl|P1}} template to rename all parameters using their value as their new name:
<syntaxhighlight lang="wikitext">{{#invoke:params|renaming_by_calling|P1|values_only|for_each|[$#: $@]}}</syntaxhighlight>
This modifier can be particularly useful for sanitizing parameter names (e.g. collapsing several spaces into single spaces, changing the [[letter case]], and so on).
Line 1,897 ⟶ 2,226:
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#converting_values_to_lowercase|converting_values_to_lowercase]]</code>, <code>[[#converting_values_to_uppercase|converting_values_to_uppercase]]</code>, <code>[[#mapping_by_calling|mapping_by_calling]]</code>, <code>[[#mapping_by_invoking|mapping_by_invoking]]</code>, <code>[[#mapping_by_magic|mapping_by_magic]]</code>, <code>[[#mapping_by_replacing|mapping_by_replacing]]</code>, <code>[[#converting_names_to_lowercase|converting_names_to_lowercase]]</code>, <code>[[#converting_names_to_uppercase|converting_names_to_uppercase]]</code>, <code>[[#renaming_by_calling|renaming_by_calling]]</code>, <code>[[#renaming_by_magic|renaming_by_magic]]</code>, <code>[[#renaming_by_replacing|renaming_by_replacing]]</code>, <code>[[#grouping_by_calling|grouping_by_calling]]</code>
}}
Line 1,926 ⟶ 2,255:
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#converting_values_to_lowercase|converting_values_to_lowercase]]</code>, <code>[[#converting_values_to_uppercase|converting_values_to_uppercase]]</code>, <code>[[#mapping_by_calling|mapping_by_calling]]</code>, <code>[[#mapping_by_invoking|mapping_by_invoking]]</code>, <code>[[#mapping_by_magic|mapping_by_magic]]</code>, <code>[[#mapping_by_replacing|mapping_by_replacing]]</code>, <code>[[#converting_names_to_lowercase|converting_names_to_lowercase]]</code>, <code>[[#converting_names_to_uppercase|converting_names_to_uppercase]]</code>, <code>[[#renaming_by_calling|renaming_by_calling]]</code>, <code>[[#renaming_by_invoking|renaming_by_invoking]]</code>, <code>[[#renaming_by_replacing|renaming_by_replacing]]</code>, <code>[[#grouping_by_calling|grouping_by_calling]]</code>
}}
Line 1,936 ⟶ 2,265:
This modifier works similarly to <code>[[#mapping_by_magic|mapping_by_magic]]</code>, but instead of replacing parameters' values '''it renames the parameters themselves'''. Care must be used knowing that if a new name collides with another new name one of the two parameters will be removed without knowing which one. New names and old names do not create collisions. If a name is returned identical it will be considered as “unchanged” and in case of conflicts the renamed one will prevail. Possible leading and trailing spaces in the new names are always stripped. Here, if omitted, the ''call style flags'' argument defaults to <code>names_only</code>.
For instance, the following example uses {{[[:mw:Special:MyLanguage/expr##expr|#expr]]}} to transform all numeric parameters into even numbers (you can replace the expression <code>%0 * 2</code> with any other expression):
<syntaxhighlight lang="wikitext">{{#invoke:params|all_sorted|excluding_non-numeric_names|renaming_by_replacing|^.*$|%0 * 2|1|renaming_by_magic|#expr|setting|h/i/p/f|[|][|: |]|list}}</syntaxhighlight>
{{vpad|clear=none}}
Line 1,955 ⟶ 2,282:
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#mapping_by_mixing|mapping_by_mixing]]</code>, <code>[[#converting_values_to_lowercase|converting_values_to_lowercase]]</code>, <code>[[#converting_values_to_uppercase|converting_values_to_uppercase]]</code>, <code>[[#mapping_by_calling|mapping_by_calling]]</code>, <code>[[#mapping_by_invoking|mapping_by_invoking]]</code>, <code>[[#mapping_by_magic|mapping_by_magic]]</code>, <code>[[#mapping_by_replacing|mapping_by_replacing]]</code>, <code>[[#converting_names_to_lowercase|converting_names_to_lowercase]]</code>, <code>[[#converting_names_to_uppercase|converting_names_to_uppercase]]</code>, <code>[[#renaming_by_calling|renaming_by_calling]]</code>, <code>[[#renaming_by_invoking|renaming_by_invoking]]</code>, <code>[[#renaming_by_magic|renaming_by_magic]]</code>, <code>[[#renaming_by_mixing|renaming_by_mixing]]</code>, <code>[[#grouping_by_calling|grouping_by_calling]]</code>, <code>[[#mixing_names_and_values]]</code>
}}
Line 1,963 ⟶ 2,290:
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|renaming_by_replacing|target|replace|[count]|[plain flag]|pipe function name}}</syntaxhighlight>
This modifier works similarly to <code>[[#mapping_by_replacing|mapping_by_replacing]]</code>, but instead of replacing parameters' values '''it renames the parameters themselves'''. Care must be used knowing that if a new name collides with another new name one of the two parameters will be removed without knowing which one. New names and old names do not create collisions. If a name is returned identical it will be considered as “unchanged” and in case of conflicts the renamed one will prevail. Possible leading and trailing spaces in the new names are always stripped (however they are not stripped while searching for the name to replace).
Since there can be only one parameter name that matches exactly a literal string, when used with the <code>strict</code> flag this modifier directly accesses the requested key without looping through the entire list of parameters (so it will be much faster).
For instance, the following example renames all parameters of type {{para|arg1}}, {{para|arg2}}, … {{para|argN}} into {{para|1}}, {{para|2}} … {{para|N}}, thus creating a novel sequence:
Line 1,970 ⟶ 2,299:
This modifier can be particularly useful for sanitizing parameter names (e.g. collapsing several spaces into single spaces, changing the [[letter case]], and so on).
For performance reasons this modifier uses <code>[[:mw:Extension:Scribunto/Lua reference manual#string.gsub|string.gsub()]]</code>; if you need to use <code>[[:mw:Extension:Scribunto/Lua reference manual#mw.ustring.gsub|mw.ustring.gsub()]]</code> instead, you will need to invoke the <code>[[Module:String#replace|replace]]</code> function from [[Module:String]] via <code>...|[[#renaming_by_invoking|renaming_by_invoking]]|[[Module:String|string]]|[[Module:String#replace|replace]]|...</code>.
The following table shows examples of equivalent instructions. Please be aware that invoking <code>[[:mw:Extension:Scribunto/Lua reference manual#mw.ustring.gsub|mw.ustring.gsub()]]</code> can be much slower.
{| class="wikitable"
|-
! <code>[[:mw:Extension:Scribunto/Lua reference manual#string.gsub|string.gsub()]]</code>
! <code>[[:mw:Extension:Scribunto/Lua reference manual#mw.ustring.gsub|mw.ustring.gsub()]]</code> (via [[Module:String]])
|-
| <code>...|renaming_by_replacing|target|replace|...</code>
| <code>...|renaming_by_invoking|string|replace|4|target|replace||false|...</code>
|-
| <code>...|renaming_by_replacing|target|replace|count|...</code>
| <code>...|renaming_by_invoking|string|replace|4|target|replace|count|false|...</code>
|-
| <code>...|renaming_by_replacing|target|replace|plain|...</code>
| <code>...|renaming_by_invoking|string|replace|2|target|replace|...</code><br />or, equivalently,<br /><code>...|renaming_by_invoking|string|replace|4|target|replace||true|...</code>
|-
| <code>...|renaming_by_replacing|target|replace|count|plain|...</code>
| <code>...|renaming_by_invoking|string|replace|3|target|replace|count|...</code><br />or, equivalently,<br /><code>...|renaming_by_invoking|string|replace|4|target|replace|count|true|...</code>
|}
There is not a corresponding translation for the <code>strict</code> flag in [[Module:String]]. However, as it goes with the <code>plain</code> flag, in that case you won't need <code>[[:mw:Extension:Scribunto/Lua reference manual#mw.ustring.gsub|mw.ustring.gsub()]]</code> in the first place.
{{vpad|clear=none}}
Line 1,977 ⟶ 2,330:
{{vpad|1.5em|clear=none}}
=== <code>renaming_by_mixing</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>renaming_by_mixing</code> <span style="nowrap">({{module:params/doc/link to the code|renaming_by_mixing|code}})</span>
| label1 = Num. of arguments | data1 = 1
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <!--<code>[[#mapping_to_names|mapping_to_names]]</code>, --><code>[[#mapping_by_mixing|mapping_by_mixing]]</code>, <code>[[#converting_values_to_lowercase|converting_values_to_lowercase]]</code>, <code>[[#converting_values_to_uppercase|converting_values_to_uppercase]]</code>, <code>[[#mapping_by_calling|mapping_by_calling]]</code>, <code>[[#mapping_by_invoking|mapping_by_invoking]]</code>, <code>[[#mapping_by_magic|mapping_by_magic]]</code>, <code>[[#converting_names_to_lowercase|converting_names_to_lowercase]]</code>, <code>[[#converting_names_to_uppercase|converting_names_to_uppercase]]</code>, <code>[[#renaming_by_calling|renaming_by_calling]]</code>, <code>[[#renaming_by_invoking|renaming_by_invoking]]</code>, <code>[[#renaming_by_magic|renaming_by_magic]]</code>, <code>[[#renaming_by_replacing|renaming_by_replacing]]</code><!--, <code>[[#renaming_to_values|renaming_to_values]]</code>-->, <code>[[#grouping_by_calling|grouping_by_calling]]</code>, <code>[[#mixing_names_and_values|mixing_names_and_values]]</code><!--, <code>[[#swapping_names_and_values|swapping_names_and_values]]</code>-->
}}
; Brief
: ''Rename all parameters, replacing their former names with the expansion of a custom string containing the <code>$#</code> and <code>$@</code> placeholders''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|renaming_by_mixing|mixing string|pipe function name}}</syntaxhighlight>
This modifier (temporarily) changes the content of the parameters the current template is being called with, replacing each of them with the expansion of a custom string that expects the same syntax as the <code>[[#for_each|for_each]]</code> function.
For instance, the following code will wrap all parameter names in quotes
<syntaxhighlight lang="wikitext">...|renaming_by_mixing|“$#”|...</syntaxhighlight>
whereas the following code will replace all parameter names with the string <code>[NAME::VALUE]</code>, where <code>NAME</code> and <code>VALUE</code> are each parameter's name and value:
<syntaxhighlight lang="wikitext">...|renaming_by_mixing|[$#::$@]|...</syntaxhighlight>
<!--
If you need to rename all parameters exactly matching their values, please use <code>[[#renaming_to_values|renaming_to_values]]</code>.
-->
{{vpad|clear=none}}
{{A note}} The ''mixing string'' argument passed to this modifier will not be trimmed of its leading and trailing spaces. The <code>renaming_by_mixing</code> modifier name itself, however, will be trimmed of their surrounding spaces.
{{vpad|1.5em|clear=none}}
<!--
=== <code>renaming_to_values</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>renaming_to_values</code> <span style="nowrap">({{module:params/doc/link to the code|renaming_to_values|code}})</span>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#mapping_to_names|mapping_to_names]]</code>, <code>[[#mapping_by_mixing|mapping_by_mixing]]</code>, <code>[[#converting_values_to_lowercase|converting_values_to_lowercase]]</code>, <code>[[#converting_values_to_uppercase|converting_values_to_uppercase]]</code>, <code>[[#mapping_by_calling|mapping_by_calling]]</code>, <code>[[#mapping_by_invoking|mapping_by_invoking]]</code>, <code>[[#mapping_by_magic|mapping_by_magic]]</code>, <code>[[#converting_names_to_lowercase|converting_names_to_lowercase]]</code>, <code>[[#converting_names_to_uppercase|converting_names_to_uppercase]]</code>, <code>[[#renaming_by_calling|renaming_by_calling]]</code>, <code>[[#renaming_by_invoking|renaming_by_invoking]]</code>, <code>[[#renaming_by_magic|renaming_by_magic]]</code>, <code>[[#renaming_by_replacing|renaming_by_replacing]]</code>, <code>[[#renaming_by_mixing|renaming_by_mixing]]</code>, <code>[[#grouping_by_calling|grouping_by_calling]]</code>, <code>[[#mixing_names_and_values|mixing_names_and_values]]</code>, <code>[[#swapping_names_and_values|swapping_names_and_values]]</code>
}}
; Brief
: ''Rename all parameters, replacing their name with their current value''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|renaming_to_values|pipe function name}}</syntaxhighlight>
This modifier does not take arguments besides the name of the function that will follow.
After calling this modifier, all parameters will have their name identical to their value. It is a shortcut for <code>...|[[#renaming_by_mixing|renaming_by_mixing]]|$@|...</code>, but slightly more efficient.
{{vpad|clear=none}}
{{A note}} The <code>renaming_to_values</code> modifier name will be trimmed of its surrounding spaces.
{{vpad|1.5em|clear=none}}
-->
=== <code>grouping_by_calling</code> ===
{{Infobox|headerstyle=background:lavender
Line 1,984 ⟶ 2,395:
| label2 = Repeatable | data2 = Yes<ref>Unless followed by <code>[[#renaming_by_replacing|renaming_by_replacing]]</code> in few bizarre situations, there is virtually no use in calling this modifier more than once.</ref>
| header3 = See also
| data4 = <code>[[#converting_values_to_lowercase|converting_values_to_lowercase]]</code>, <code>[[#converting_values_to_uppercase|converting_values_to_uppercase]]</code>, <code>[[#call_for_each_group|call_for_each_group]]</code>, <code>[[#mapping_by_calling|mapping_by_calling]]</code>, <code>[[#mapping_by_invoking|mapping_by_invoking]]</code>, <code>[[#mapping_by_magic|mapping_by_magic]]</code>, <code>[[#mapping_by_replacing|mapping_by_replacing]]</code>, <code>[[#converting_names_to_lowercase|converting_names_to_lowercase]]</code>, <code>[[#converting_names_to_uppercase|converting_names_to_uppercase]]</code>, <code>[[#renaming_by_calling|renaming_by_calling]]</code>, <code>[[#renaming_by_invoking|renaming_by_invoking]]</code>, <code>[[#renaming_by_magic|renaming_by_magic]]</code>, <code>[[#renaming_by_replacing|renaming_by_replacing]]</code>
}}
; Brief
: ''Group the parameters that have the same
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|grouping_by_calling|template name|[let]|[...]|[number of additional arguments]|[argument 1]|[argument 2]|[...]|[argument N]|pipe function name}}</syntaxhighlight>
This is the piping version of <code>[[#call_for_each_group|call_for_each_group]]</code>. This means that after calling this modifier the old parameters will be (temporarily) gone and the only parameters left will be novel parameters whose names will be numbers (or an empty string if parameters without a
Like other modifiers in the <code>mapping_*</code> and <code>renaming_*</code> family, it is possible to impose own parameters on the callback template by using the syntax <code>...|[let]|[...]|[number of additional arguments]|[argument 1]|[argument 2]|[...]|[argument N]|...</code>. Unlike the other <code>mapping_*</code> and <code>renaming_*</code> modifiers, however (but like <code>[[#call_for_each_group|call_for_each_group]]</code>), sequential parameters here will not be prepended, but will ''replace'' possible parsed parameters.
Line 2,013 ⟶ 2,424:
{{vpad|1.5em|clear=none}}
=== <code>parsing</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>parsing</code> <span style="nowrap">({{module:params/doc/link to the code|parsing|code}})</span>
| label1 = Num. of arguments | data1 = 1–6
| label2 = Repeatable | data2 = Yes
| label3 = Often accompanied by | data3 = <code>[[#new|new]]</code>
| header4 = See also
| data5 = <code>[[#new|new]]</code>, <code>{{mfl|ArrayList}}</code>, <code>{{tl|Array}}</code>
}}
; Brief
: ''Create new parameters by parsing a parameter string''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|parsing|string to parse|[trim flag]|[iteration delimiter setter]|[...]|[key-value delimiter setter]|[...]|pipe function name}}</syntaxhighlight>
This modifier allows to add an infinity of new parameters by using a parameter string. By default this expects <code>|</code> as separator between parameters and <code>=</code> as separator between keys and values, but it is possible to specify other strings or patterns. The parsed parameters will overwrite existing parameters of the same name. For this reason, the <code>[[#new|new]]</code> directive often accompanies this modifier.
Examples:
* <syntaxhighlight lang="wikitext" inline>{{#invoke:params|new|parsing|one{{!}}two{{!}}three{{!}}foo{{=}}bar{{!}}hello{{=}}world|for_each|[$#:$@]}}</syntaxhighlight>
*: ↳ {{#invoke:params|new|parsing|one{{!}}two{{!}}three{{!}}foo{{=}}bar{{!}}hello{{=}}world|for_each|[$#:$@]}}
* <syntaxhighlight lang="wikitext" inline>{{#invoke:params|new|parsing|one, two; three. foo: bar, hello: world|trim_all|splitter_pattern|[,;.]|setter_string|:|for_each|[$#:$@]}}</syntaxhighlight>
*: ↳ {{#invoke:params|new|parsing|one, two; three. foo: bar, hello: world|trim_all|splitter_pattern|[,;.]|setter_string|:|for_each|[$#:$@]}}
* <syntaxhighlight lang="wikitext" inline>{{#invoke:params|new|parsing|one/two/ three / foo % bar /hello%world|setter_string|%|trim_none|splitter_string|/|for_each|[$#:$@]}}</syntaxhighlight>
*: ↳ {{#invoke:params|new|parsing|one/two/ three / foo % bar /hello%world|setter_string|%|trim_none|splitter_string|/|for_each|[$#:$@]}}
The ''trim flag'' argument can be placed in any position after the ''string to parse'' (not necessarily in second position) and can have one of the following values: <code>trim_none</code>, <code>trim_named</code>, <code>trim_positional</code>, <code>trim_all</code>. If omitted, it defaults to <code>trim_named</code>.
The ''iteration delimiter setter'' can be placed in any position after the ''string to parse'' (not necessarily in third position), must be ''immediately'' followed by a user-given string, and can be either <code>splitter_string</code> or <code>splitter_pattern</code>. If omitted, the two arguments default to <code>splitter_string|{{!}}</code>. If the custom string is empty (but not if it is blank but not empty) the string to parse will be assumed not to have any iteration delimiters (this will result in one single parameter being parsed).
The ''key-value delimiter setter'' can be placed in any position after the ''string to parse'' (not necessarily in fifth position), must be ''immediately'' followed by a user-given string, and can be either <code>setter_string</code> or <code>setter_pattern</code>. If omitted, the two arguments default to <code>setter_string|{{=}}</code>. If the custom string is empty (but not if it is blank but not empty) the string to parse will be assumed not to have any key-value delimiters (this will result in a sequence-only list of parameters being parsed).
{| class="wikitable" style="margin-left: auto; margin-right: auto;"
|+ Possible options
|-
! Setting a trim flag
! Setting an iteration delimiter
! Setting a key-value delimiter
|-
| <code>trim_none</code><br /> <code>trim_named</code><br /> <code>trim_positional</code><br /> <code>trim_all</code>
| <code>splitter_string|...</code><br /> <code>splitter_pattern|...</code>
| <code>setter_string|...</code><br /> <code>setter_pattern|...</code>
|}
{{vpad|clear=none}}
{{A note}} All arguments passed to this modifier except the <code>parsing</code> modifier name itself, the ''trim flag'', ''iteration delimiter setter'' and ''key-value delimiter setter'' arguments will not be trimmed of their leading and trailing spaces.
{{vpad|1.5em|clear=none}}
=== <code>reinterpreting</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>reinterpreting</code> <span style="nowrap">({{module:params/doc/link to the code|reinterpreting|code}})</span>
| label1 = Num. of arguments | data1 = 1–6
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#parsing|parsing]]</code>, <code>{{mfl|ArrayList}}</code>, <code>{{tl|Array}}</code>
}}
; Brief
: ''Use the content of a parameter as a parameter string to parse, after removing the parameter itself''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|reinterpreting|parameter name|[trim flag]|[iteration delimiter setter]|[...]|[key-value delimiter setter]|[...]|pipe function name}}</syntaxhighlight>
This modifier works exactly like <code>[[#parsing|parsing]]</code>, but takes the content of a disposable parameter as input. See there for further information. The parameter passed to this modifier will be immediately deleted. The parsed parameters will overwrite existing parameters of the same name.
Example:
<syntaxhighlight lang="wikitext">{{#invoke:params|new|pulling|1|reinterpreting|1|splitter_string|,|trim_all|concat_and_call|See also}}</syntaxhighlight>
An example that shows how to use this function to transclude a custom template with custom parameters is available at {{{{rel|Module:Params/doc/examples/constructed transclusion}}}}.
{{vpad|clear=none}}
{{A note}} All arguments passed to this modifier except the <code>reinterpreting</code> modifier name itself, the ''parameter name'', the ''trim flag'', ''iteration delimiter setter'' and ''key-value delimiter setter'' arguments will not be trimmed of their leading and trailing spaces.
{{vpad|1.5em|clear=none}}
=== <code>mixing_names_and_values</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>mixing_names_and_values</code> <span style="nowrap">({{module:params/doc/link to the code|mixing_names_and_values|code}})</span>
| label1 = Num. of arguments | data1 = 2
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <!--<code>[[#mapping_to_names|mapping_to_names]]</code>, --><code>[[#mapping_by_mixing|mapping_by_mixing]]</code>, <code>[[#converting_values_to_lowercase|converting_values_to_lowercase]]</code>, <code>[[#converting_values_to_uppercase|converting_values_to_uppercase]]</code>, <code>[[#mapping_by_calling|mapping_by_calling]]</code>, <code>[[#mapping_by_invoking|mapping_by_invoking]]</code>, <code>[[#mapping_by_magic|mapping_by_magic]]</code>, <code>[[#converting_names_to_lowercase|converting_names_to_lowercase]]</code>, <code>[[#converting_names_to_uppercase|converting_names_to_uppercase]]</code>, <code>[[#renaming_by_calling|renaming_by_calling]]</code>, <code>[[#renaming_by_invoking|renaming_by_invoking]]</code>, <code>[[#renaming_by_magic|renaming_by_magic]]</code>, <code>[[#renaming_by_replacing|renaming_by_replacing]]</code>, <code>[[#renaming_by_mixing|renaming_by_mixing]]</code><!--, <code>[[#renaming_to_values|renaming_to_values]]</code>-->, <code>[[#grouping_by_calling|grouping_by_calling]]</code><!--, <code>[[#swapping_names_and_values|swapping_names_and_values]]</code>-->
}}
; Brief
: ''Rewrite all parameters, replacing names and values with the expansion of two custom strings containing the <code>$#</code> and <code>$@</code> placeholders''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|mixing_names_and_values|name mixing string|value mixing string|pipe function name}}</syntaxhighlight>
This modifier (temporarily) changes names and values of the parameters the current template is being called with, replacing each of them with the expansion of two custom strings that expect the same syntax as the <code>[[#for_each|for_each]]</code> function.
For instance, the following code will wrap all parameter names and values in quotes
<syntaxhighlight lang="wikitext">...|mixing_names_and_values|“$#”|“$@”|...</syntaxhighlight>
whereas the following code will replace all names with the string <code>VALUE/NAME</code> and all values with the string <code>[NAME::VALUE]</code>, where <code>NAME</code> and <code>VALUE</code> are each parameter's name and value:
<syntaxhighlight lang="wikitext">...|mixing_names_and_values|$@/$#|[$#::$@]|...</syntaxhighlight>
<!--
If you need to swap names and values verbatim, please use <code>[[#swapping_names_and_values|swapping_names_and_values]]</code>.
-->
{{vpad|clear=none}}
{{A note}} The ''value mixing string'' argument passed to this modifier will not be trimmed of its leading and trailing spaces. The ''name mixing string'' argument and <code>mixing_names_and_values</code> modifier name itself, however, will be trimmed of their surrounding spaces.
{{vpad|1.5em|clear=none}}
<!--
=== <code>swapping_names_and_values</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>swapping_names_and_values</code> <span style="nowrap">({{module:params/doc/link to the code|swapping_names_and_values|code}})</span>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#mapping_to_names|mapping_to_names]]</code>, <code>[[#mapping_by_mixing|mapping_by_mixing]]</code>, <code>[[#converting_values_to_lowercase|converting_values_to_lowercase]]</code>, <code>[[#converting_values_to_uppercase|converting_values_to_uppercase]]</code>, <code>[[#mapping_by_calling|mapping_by_calling]]</code>, <code>[[#mapping_by_invoking|mapping_by_invoking]]</code>, <code>[[#mapping_by_magic|mapping_by_magic]]</code>, <code>[[#converting_names_to_lowercase|converting_names_to_lowercase]]</code>, <code>[[#converting_names_to_uppercase|converting_names_to_uppercase]]</code>, <code>[[#renaming_by_calling|renaming_by_calling]]</code>, <code>[[#renaming_by_invoking|renaming_by_invoking]]</code>, <code>[[#renaming_by_magic|renaming_by_magic]]</code>, <code>[[#renaming_by_replacing|renaming_by_replacing]]</code>, <code>[[#renaming_by_mixing|renaming_by_mixing]]</code>, <code>[[#renaming_to_values|renaming_to_values]]</code>, <code>[[#grouping_by_calling|grouping_by_calling]]</code>, <code>[[#mixing_names_and_values|mixing_names_and_values]]</code>
}}
; Brief
: ''Rewrite all parameters swapping their names and values''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|swapping_names_and_values|pipe function name}}</syntaxhighlight>
This modifier does not take arguments besides the name of the function that will follow.
This modifier is a shortcut for <code>...|[[#mixing_names_and_values|mixing_names_and_values]]|$@|$#|...</code>, but slightly more efficient.
{{vpad|clear=none}}
{{A note}} The <code>swapping_names_and_values</code> modifier name will be trimmed of its surrounding spaces.
{{vpad|1.5em|clear=none}}
-->
=== <code>combining_by_calling</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>combining_by_calling</code> <span style="nowrap">({{module:params/doc/link to the code|combining_by_calling|code}})</span>
| label1 = Num. of arguments | data1 = 2
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#entering_substack|entering_substack]]</code>, <code>[[#snapshotting|snapshotting]]</code>, <code>[[#remembering|remembering]]</code>, <code>[[#concat_and_call|concat_and_call]]</code>
}}
; Brief
: ''Pass all current parameters to a custom template and save the returned output as a new parameter''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|combining_by_calling|template name|new parameter name|pipe function name}}</syntaxhighlight>
This is the piping version of <code>[[#concat_and_call|concat_and_call]]</code>. This means that after calling this modifier the old parameters will be (temporarily) gone and the only parameter left will be what is specified in the ''new parameter name'' argument.
Since after using this modifier all parameters will be grouped into one single parameter, to pass additional parameters to the callback template you can safely use <code>[[#imposing|imposing]]</code> or <code>[[#parsing|parsing]]</code>.
For instance, using {{rel|Module:Params/testcases/tdummy echo sb}} as callback template, a template named <syntaxhighlight lang="wikitext" inline>{{example template}}</syntaxhighlight> with the following content,
<syntaxhighlight lang="wikitext">{{#invoke:params|combining_by_calling|module:params/testcases/tdummy echo sb|my_new_param|for_each|[$#:$@]}}</syntaxhighlight>
when transcluded as <syntaxhighlight lang="wikitext" inline>{{example template|one|two|three|hello=world|foo=bar}}</syntaxhighlight> will produce
: {{#invoke:params|new|
imposing|1|one|
imposing|2|two|
imposing|3|three|
imposing|hello|world|
imposing|foo|bar|
combining_by_calling|module:params/testcases/tdummy echo sb|my_new_param|for_each|[$#:$@]}}
{{vpad|1.5em|clear=none}}
=== <code>snapshotting</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>snapshotting</code> <span style="nowrap">({{module:params/doc/link to the code|snapshotting|code}})</span>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| label3 = Eventually followed by | data3 = Either <code>[[#entering_substack|entering_substack]]</code> or <code>[[#flushing|flushing]]</code>
| header4 = See also
| data5 = <code>[[#remembering|remembering]]</code>, <code>[[#entering_substack|entering_substack]]</code>, <code>[[#pulling|pulling]]</code>, <code>[[#merging_substack|merging_substack]]</code>, <code>[[#detaching_substack|detaching_substack]]</code>, <code>[[#leaving_substack|leaving_substack]]</code>, <code>[[#flushing|flushing]]</code>
}}
; Brief
: ''Push a copy of the current parameter list to the queue of parameter lists''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|snapshotting|pipe function name}}</syntaxhighlight>
This modifier does not take arguments besides the name of the function that will follow.
This module has a stacking mechanism that allows to isolate groups of parameters, work separately on them, and then merge them back to the original stack. The modifiers dedicated to this mechanism are:
* <code>[[#snapshotting|snapshotting]]</code>
* <code>[[#remembering|remembering]]</code>
* <code>[[#entering_substack|entering_substack]]</code>
* <code>[[#pulling|pulling]]</code>
* <code>[[#detaching_substack|detaching_substack]]</code>
* <code>[[#leaving_substack|leaving_substack]]</code>
* <code>[[#merging_substack|merging_substack]]</code>
* <code>[[#flushing|flushing]]</code>
Every time the <code>snapshotting</code> modifier is used, the current list of parameters (together with their values) will be copied and added to a queue. When the <code>[[#entering_substack|entering_substack]]</code> modifier is used, the list of parameters on top of the queue will temporarily become the current parameters, and all other modifiers will affect only this substack. After completing the job, the <code>[[#merging_substack|merging_substack]]</code> will merge the current substack to the parent stack.
If no parameter lists have been snapshotted before calling <code>[[#entering_substack|entering_substack]]</code>, the latter will automatically make a snapshot of the current parameters. Once inside a substack, it is possible to enter a subsubstack using the same machinery.
The <code>[[#detaching_substack|detaching_substack]]</code> modifier erases the current parameters from the parent stack, allowing the current stack to rename its parameters freely and merge them back to the parent stack, renamed.
It is possible to leave a substack without merging it to the parent by using the <code>[[#leaving_substack|leaving_substack]]</code> modifier. In this case, at some point it will be necessary to call <code>[[#flushing|flushing]]</code> in order to merge the stack previously left unmerged. Alternatively, it will be possible to enter it again by calling <code>[[#entering_substack|entering_substack]]</code>, and finally merge it via <code>[[#merging_substack|merging_substack]]</code>.
An example will probably clarify the mechanism better than anything else:
<syntaxhighlight lang="wikitext">{{#invoke:params|new|<!-- Ignore the incoming parameters and manually assign some parameters (we will simulate the following incoming parameters: |one|two|three|four|foo=bar|hello=world ...) -->
imposing|1|one|
imposing|2|two|
imposing|3|three|
imposing|4|four|
imposing|foo|bar|
imposing|hello|world|
entering_substack|<!-- Enter into a substack (the `snapshotting` modifier will be automatically invoked for us) -->
excluding_numeric_names|<!-- Exclude numeric parameters -->
detaching_substack|<!-- Remove the current parameters from the parent stack -->
renaming_by_replacing|^.*$|This was called “%0”|1|<!-- Rename all parameters -->
merging_substack|
entering_substack|new|<!-- Enter into a new empty substack -->
pulling|1|<!-- Pull the parameter named “1” from the parent stack -->
mapping_by_replacing|^.*$|This value once was “%0”|1|<!-- Replace the content of all parameters -->
merging_substack|
for_each|[$#:$@]}}</syntaxhighlight>
The code above will result in:
: {{#invoke:params|new|<!-- Ignore the incoming parameters and manually assign some parameters (we will simulate the following incoming parameters: |one|two|three|four|foo=bar|hello=world ...) -->
imposing|1|one|
imposing|2|two|
imposing|3|three|
imposing|4|four|
imposing|foo|bar|
imposing|hello|world|
entering_substack|<!-- Enter into a substack (the `snapshotting` modifier will be automatically invoked for us) -->
excluding_numeric_names|<!-- Exclude numeric parameters -->
detaching_substack|<!-- Remove the current parameters from the parent stack -->
renaming_by_replacing|^.*$|This was called “%0”|1|<!-- Rename all parameters -->
merging_substack|
entering_substack|new|<!-- Enter into a new empty substack -->
pulling|1|<!-- Pull the parameter named “1” from the parent stack -->
mapping_by_replacing|^.*$|This value once was “%0”|1|<!-- Replace the content of all parameters -->
merging_substack|
for_each|[$#:$@]}}
{{vpad|1.5em|clear=none}}
=== <code>remembering</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>remembering</code> <span style="nowrap">({{module:params/doc/link to the code|remembering|code}})</span>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| label3 = Eventually followed by | data3 = Either <code>[[#entering_substack|entering_substack]]</code> or <code>[[#flushing|flushing]]</code>
| header4 = See also
| data5 = <code>[[#snapshotting|snapshotting]]</code>, <code>[[#entering_substack|entering_substack]]</code>, <code>[[#pulling|pulling]]</code>, <code>[[#merging_substack|merging_substack]]</code>, <code>[[#detaching_substack|detaching_substack]]</code>, <code>[[#leaving_substack|leaving_substack]]</code>, <code>[[#flushing|flushing]]</code>
}}
; Brief
: ''Push a copy of the original (unmodified) parameter list to the queue of snapshots''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|remembering|pipe function name}}</syntaxhighlight>
This modifier does not take arguments besides the name of the function that will follow.
This modifier is somewhat similar to <code>[[#snapshotting|snapshotting]]</code>, except that it retrieves the parameters that were originally passed to the calling template before being affected by the module's modifiers. The modifier works also after the <code>[[#new|new]]</code> directive. See <code>[[#snapshotting|snapshotting]]</code> for more information on the stacking mechanism.
{{vpad|1.5em|clear=none}}
=== <code>entering_substack</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>entering_substack</code> <span style="nowrap">({{module:params/doc/link to the code|entering_substack|code}})</span>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| label3 = May be immediately followed by | data3 = <code>[[#new|new]]</code>
| label4 = Eventually followed by | data4 = Either <code>[[#merging_substack|merging_substack]]</code> or <code>[[#leaving_substack|leaving_substack]]</code> followed by <code>[[#flushing|flushing]]</code>
| header5 = See also
| data6 = <code>[[#snapshotting|snapshotting]]</code>, <code>[[#remembering|remembering]]</code>, <code>[[#pulling|pulling]]</code>, <code>[[#merging_substack|merging_substack]]</code>, <code>[[#detaching_substack|detaching_substack]]</code>, <code>[[#leaving_substack|leaving_substack]]</code>, <code>[[#flushing|flushing]]</code>
}}
; Brief
: ''Enter the first stack in the queue of parameter lists, or copy the current parameters into a substack if the queue is empty''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|entering_substack|[new]|pipe function name}}</syntaxhighlight>
This modifier does not take arguments besides the name of the function that will follow.
See <code>[[#snapshotting|snapshotting]]</code> for more information on the stacking mechanism. Once in a substack, it is possible to go back to the parent stack using two different modifiers: <code>[[#merging_substack|merging_substack]]</code> and <code>[[#leaving_substack|leaving_substack]]</code>.
{{vpad|1.5em|clear=none}}
=== <code>pulling</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>pulling</code> <span style="nowrap">({{module:params/doc/link to the code|pulling|code}})</span>
| label1 = Num. of arguments | data1 = 1
| label2 = Repeatable | data2 = Yes
| label3 = Often preceeded by | data3 = <code>[[#new|new]]</code>
| header4 = See also
| data5 = <code>[[#snapshotting|snapshotting]]</code>, <code>[[#remembering|remembering]]</code>, <code>[[#merging_substack|merging_substack]]</code>, <code>[[#detaching_substack|detaching_substack]]</code>, <code>[[#leaving_substack|leaving_substack]]</code>, <code>[[#flushing|flushing]]</code>
}}
; Brief
: ''Pull a single parameter from the parent stack or from the stack of the original parameters''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|pulling|parameter name|pipe function name}}</syntaxhighlight>
See <code>[[#snapshotting|snapshotting]]</code> for more information on the stacking mechanism. If this modifer is not used in a substack, the parameter will be pulled from the original (unmodified) parameter list.
{{vpad|1.5em|clear=none}}
=== <code>detaching_substack</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>detaching_substack</code> <span style="nowrap">({{module:params/doc/link to the code|detaching_substack|code}})</span>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| label3 = Restrictions | data3 = Usable only inside substacks
| header4 = See also
| data5 = <code>[[#snapshotting|snapshotting]]</code>, <code>[[#remembering|remembering]]</code>, <code>[[#entering_substack|entering_substack]]</code>, <code>[[#pulling|pulling]]</code>, <code>[[#merging_substack|merging_substack]]</code>, <code>[[#leaving_substack|leaving_substack]]</code>, <code>[[#flushing|flushing]]</code>
}}
; Brief
: ''Remove from the parent stack the parameters that are present in the current stack''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|detaching_substack|pipe function name}}</syntaxhighlight>
This modifier does not take arguments besides the name of the function that will follow.
This modifer can only be used in a substack. See <code>[[#snapshotting|snapshotting]]</code> for more information on the stacking mechanism.
{{vpad|1.5em|clear=none}}
=== <code>leaving_substack</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>leaving_substack</code> <span style="nowrap">({{module:params/doc/link to the code|leaving_substack|code}})</span>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| label3 = Restrictions | data3 = Usable only inside substacks
| header4 = See also
| data5 = <code>[[#snapshotting|snapshotting]]</code>, <code>[[#remembering|remembering]]</code>, <code>[[#entering_substack|entering_substack]]</code>, <code>[[#pulling|pulling]]</code>, <code>[[#merging_substack|merging_substack]]</code>, <code>[[#detaching_substack|detaching_substack]]</code>, <code>[[#flushing|flushing]]</code>
}}
; Brief
: ''Leave the current substack without merging it, and return to the parent stack''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|leaving_substack|pipe function name}}</syntaxhighlight>
This modifier does not take arguments besides the name of the function that will follow.
This modifer can only be used in a substack. See <code>[[#snapshotting|snapshotting]]</code> for more information on the stacking mechanism.
See <code>[[#flushing|flushing]]</code> for an example of how to use this modifier.
{{vpad|1.5em|clear=none}}
=== <code>merging_substack</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>merging_substack</code> <span style="nowrap">({{module:params/doc/link to the code|merging_substack|code}})</span>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| label3 = Restrictions | data3 = Usable only inside substacks
| header4 = See also
| data5 = <code>[[#snapshotting|snapshotting]]</code>, <code>[[#remembering|remembering]]</code>, <code>[[#entering_substack|entering_substack]]</code>, <code>[[#pulling|pulling]]</code>, <code>[[#detaching_substack|detaching_substack]]</code>, <code>[[#leaving_substack|leaving_substack]]</code>, <code>[[#flushing|flushing]]</code>
}}
; Brief
: ''Leave the current stack after merging it with the parent stack, then return to the latter''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|merging_substack|pipe function name}}</syntaxhighlight>
This modifier does not take arguments besides the name of the function that will follow.
This modifer can only be used in a substack. See <code>[[#snapshotting|snapshotting]]</code> for more information on the stacking mechanism.
{{vpad|1.5em|clear=none}}
=== <code>flushing</code> ===
{{Infobox|headerstyle=background:lavender
| titlestyle = font-weight:normal; font-size:100%;
| title = Modifier <code>flushing</code> <span style="nowrap">({{module:params/doc/link to the code|flushing|code}})</span>
| label1 = Num. of arguments | data1 = 0
| label2 = Repeatable | data2 = Yes
| header3 = See also
| data4 = <code>[[#snapshotting|snapshotting]]</code>, <code>[[#remembering|remembering]]</code>, <code>[[#entering_substack|entering_substack]]</code>, <code>[[#pulling|pulling]]</code>, <code>[[#merging_substack|merging_substack]]</code>, <code>[[#detaching_substack|detaching_substack]]</code>, <code>[[#leaving_substack|leaving_substack]]</code>
}}
; Brief
: ''Merge the first stack in the queue of snapshotted parameters with the current stack.''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|flushing|pipe function name}}</syntaxhighlight>
This modifier does not take arguments besides the name of the function that will follow.
This modifier is used in conjunction with either <code>[[#leaving_substack|leaving_substack]]</code> or <code>[[#snapshotting|snapshotting]]</code>. See <code>[[#snapshotting|snapshotting]]</code> for more information on the stacking mechanism.
In the following wrapper of an <syntaxhighlight lang="wikitext" inline>{{example template}}</syntaxhighlight>, the three parameters {{para|1}}, {{para|2}}, and {{para|3}} are used as aliases for {{para|title}}, {{para|author}}, and {{para|language}} respectively. The <code>flushing</code> modifier ensures that in case both are present, the named alias will have the precedence over the positional alias.
<syntaxhighlight lang="wikitext">{{#invoke:params|
entering_substack|
discarding|1|
discarding|2|
discarding|3|
leaving_substack|
renaming_by_replacing|1|title|strict|
renaming_by_replacing|2|author|strict|
renaming_by_replacing|3|language|strict|
flushing|
concat_and_call|example template}}</syntaxhighlight>
{{vpad|1.5em|clear=none}}
=== <code>new</code> ===
{{Infobox|headerstyle=background:lavender
Line 2,022 ⟶ 2,854:
| label3 = Restrictions | data3 = First position only
| header4 = See also
| data5 = <code>[[#parsing|parsing]]</code>, <code>[[#imposing|imposing]]</code>, <code>[[#providing|providing]]</code><!--, <code>[[#inserting|inserting]]</code>-->, <code>[[#discarding|discarding]]</code>
}}
; Brief
: ''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|new|pipe function name}}</syntaxhighlight>
This modifier does not take arguments besides the name of the function that will follow.
This modifier can only appear in first position, or if substacks are present, immediately after the <code>[[#entering_substack|entering_substack]]</code> directive. When in first position its main purpose is that of extending the facilities offered by this module (e.g. <code>[[#mapping_by_replacing|mapping_by_replacing]]</code>, <code>[[#with_value_matching|with_value_matching]]</code>, etc.) to custom lists of strings, independently of the incoming parameters. When inside a stack, it signals that the snapshot of the current parameters must be ignored for that stack. The existence of the <code>new</code> modifier also facilitates debugging the module.
The newly created parameter stack can be populated via <code>[[#
Examples:
Line 2,039 ⟶ 2,873:
{{vpad|1.5em|clear=none}}
== Subpages ==
* [[Module:Params/ChangeLog]] – Record of the most important changes in the module's code
Line 2,062 ⟶ 2,896:
* {{ml|For loop|main}} and {{tl|For loop}}
* {{ml|For nowiki|template}} and {{tl|For nowiki}}
* {{ml|Template wrapper|wrap}}
* {{ml|ArrayList}}
* [[Project:TemplateData]]
|