Content deleted Content added
+note |
m →cutting: emphasis |
||
(16 intermediate revisions by 2 users not shown) | |||
Line 176:
: <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 389:
<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
Line 732:
}}
See also {{{{rel|Module:Params/doc/examples/tablebox}}}} for an example of how to exploit this function to create [[Template:Infobox|infoboxes]], and {{{{rel|Module:Params/doc/examples/four cells per row table}}}} for an example of how to exploit this function to create n-column tables.
{{vpad|clear=none}}
Line 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,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''' other positive numeric parameters will be shifted accordingly.
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,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>[[#
}}
Line 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>[[#
}}
Line 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>[[#
}}
Line 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>[[#
}}
Line 1,266:
: ''Reverse the order of all numeric parameters (not only sequential ones), making sure that the largest numeric parameter and {{para|1}} are swapped''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|
This modifier does not take arguments besides the name of the function that will follow.
Line 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|
<!--
{{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>[[#
}}
Line 1,292:
: ''Reverse the order of all numeric parameters (not only sequential ones)''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|
This modifier does not take arguments besides the name of the function that will follow.
Line 1,300:
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>[[#
}}
Line 1,318:
: ''Reverse the order of all numeric parameters (not only sequential ones), '''keeping the parameters' sequence always centered'''''
; 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 numeric parameters, making sure that those in the parameters' sequence always remain in the sequence. As a consequence, the values of the minimum and the maximum numeric parameters may change. If no sequence is present this modifier is identical to <code>[[#
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>[[#
}}
Line 1,344:
: ''Swap the lowest numeric parameter with the highest, the second lowest with the second highest, and so on, keeping the sequence in the same place albeit in reverse order''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|
This modifier does not take arguments besides the name of the function that will follow.
Line 1,350:
Example:
<syntaxhighlight lang="wikitext">{{#invoke:params|
-->
{{vpad|1.5em|clear=none}}
Line 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,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>[[#
}}
Line 1,410:
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>
Line 1,423:
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||||
Line 1,834:
: ''Convert all parameter values to upper case''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|
This modifier does not take arguments besides the name of the function that will follow.
Line 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,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,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 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 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.
Line 2,052 ⟶ 2,076:
{{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> ===
Line 2,072 ⟶ 2,155:
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
{{vpad|1.5em|clear=none}}
Line 2,089 ⟶ 2,172:
: ''Convert all parameter names to upper case''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|
This modifier does not take arguments besides the name of the function that will follow.
Line 2,095 ⟶ 2,178:
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
{{vpad|1.5em|clear=none}}
Line 2,123 ⟶ 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 2,195 ⟶ 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 2,212 ⟶ 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 2,219 ⟶ 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 2,335 ⟶ 2,504:
{{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> ===
|