Content deleted Content added
mNo edit summary |
→setting: Move the examples on top |
||
Line 471:
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|setting|directives|...|pipe function name}}</syntaxhighlight>
This modifier allows to set some internal variables that will be used by other functions. The function takes a variable number of arguments, relying on the first argument to understand how many other arguments to read. It will be best introduced by a few examples:
* <syntaxhighlight lang="wikitext" inline>{{#invoke:params|setting|i|{{!}}|list_values}}</syntaxhighlight>▼
*: ↳ Set the value of ''iteration delimiter'' to <code>|</code>, then list all values▼
* <syntaxhighlight lang="wikitext" inline>{{#invoke:params|setting|ih|{{!}}|list_values}}</syntaxhighlight>▼
*: ↳ Set the value of both ''header text'' and ''iteration delimiter'' to <code>|</code>, then list all values▼
* <syntaxhighlight lang="wikitext" inline>{{#invoke:params|setting|ih/p|{{!}}|{{=}}|list}}</syntaxhighlight>▼
*: ↳ Set the value of both ''header text'' and ''iteration delimiter'' to <code>|</code>, set ''key-value pair delimiter'' to <code>=</code>, then list all parameters▼
* <syntaxhighlight lang="wikitext" inline>{{#invoke:params|setting|ih/p/n|{{!}}|{{=}}|No parameters were passed|list}}</syntaxhighlight>▼
*: ↳ Set the value of both ''header text'' and ''iteration delimiter'' to <code>|</code>, set ''key-value pair delimiter'' to <code>=</code>, set ''fallback text'' to <code>No parameters were passed</code>, then list all parameters▼
The first argument is a slash-separated list of lists of slots to assign; one slot is referred by exactly one character and each slash-separated list of slots maps exactly one argument. A slot indicates which internal variable to set. If more than one slot is aggregated within the same slash-separated list the same text will be assigned to more than one variable.
Line 503 ⟶ 512:
| The string of text that will be placed if there are no parameters to show.
|}
▲* <syntaxhighlight lang="wikitext" inline>{{#invoke:params|setting|i|{{!}}|list_values}}</syntaxhighlight>
▲*: ↳ Set the value of ''iteration delimiter'' to <code>|</code>, then list all values
▲* <syntaxhighlight lang="wikitext" inline>{{#invoke:params|setting|ih|{{!}}|list_values}}</syntaxhighlight>
▲*: ↳ Set the value of both ''header text'' and ''iteration delimiter'' to <code>|</code>, then list all values
▲* <syntaxhighlight lang="wikitext" inline>{{#invoke:params|setting|ih/p|{{!}}|{{=}}|list}}</syntaxhighlight>
▲*: ↳ Set the value of both ''header text'' and ''iteration delimiter'' to <code>|</code>, set ''key-value pair delimiter'' to <code>=</code>, then list all parameters
▲* <syntaxhighlight lang="wikitext" inline>{{#invoke:params|setting|ih/p/n|{{!}}|{{=}}|No parameters were passed|list}}</syntaxhighlight>
▲*: ↳ Set the value of both ''header text'' and ''iteration delimiter'' to <code>|</code>, set ''key-value pair delimiter'' to <code>=</code>, set ''fallback text'' to <code>No parameters were passed</code>, then list all parameters
In theory, instead of assigning different slots at once (i.e. <syntaxhighlight lang="wikitext" inline>{{...|setting|ih/p|{{!}}|{{=}}|...}}</syntaxhighlight>), it is possible to write separate invocations of <code>setting</code> for each variable, as in <syntaxhighlight lang="wikitext" inline>{{...|setting|ih|{{!}}|setting|p|{{=}}...}}</syntaxhighlight>. This method will be slightly less efficient.
|