ਮੌਡਿਊਲ:Xpd/doc
This is the documentation page for ਮੌਡਿਊਲ:Xpd
This module is invoked from Template:Xpds, Template:Xpdp, Template:Xpdws and Template:Xpdwp (w = show wikitext produced, s = same line, p = new paragraph), expansion demo templates that show the call of a variable, parser function or template, optionally its resulting wikitext, and the latter's rendering. It is also invoked from Template:Xpdplains and Template:Xpdplainp, templates that show plain wikitext and its rendering. They are used for testing and documenting variables, parser functions, templates, and wikitext and html features. The technical notes below apply partly to all templates, partly to the first four only.
For parameters with explicit positive integer names the integer is reduced by 1 in the result (just like for implicit names, due to the position taken by the template name in the calls of the templates xpds and xpdp).
Expressions for parameter values are replaced by their results.
Without affecting the result the template call is written in a normalized form:
- Values of named parameters are trimmed.[1]
- Definitions of parameters with implicit or explicit positive integer names are ordered in ascending order.[1] Explicit names among them are removed. These parameters are put before the remaining ones.[1] Multiple definitions of the same parameter are replaced by the final one.[1]
- In the parameter names and values (after the expansion mentioned above) any braces, pipes and/or equal signs are changed into
{{(}}
,{{)}}
,{{!}}
, and{{=}}
, so that the parsing of the call is kept intact.[2]
Examples:
{{xpds|Foreach|SeeHook|delim=,|abc|4= ParserBeforeStrip |3= ParserAfterStrip |delim= / }}
gives:
{{Foreach|SeeHook|ParserAfterStrip|ParserBeforeStrip|delim=/}}
→ ਫਰਮਾ:Foreach
Wikitext on the left
ਸੋਧੋTo display on the left-hand side the wikitext and not the rendering of the parameter values, some adjustments are made at that side[3]:
&
is replaced by&
- square brackets are replaced by
[
and]
- newlines are replaced by
<br>
- spaces are replaced by
Examples:
{{xpds|2x|[[abc]] }}
→
{{2x|*abc
→
}}
- abc
- abc
{{2x| a{{!}}b }}
→ a|b a|b
{{2x| a{{=}}b }}
→ a=b a=b
{{2x| a{{(}}{{(}}b }}
→ a{{b a{{b
{{2x| a{{)}}{{)}}b }}
→ a}}b a}}b
Limitation
ਸੋਧੋParameters with explicit or implicit positive integer names have to form a set {1, 2, .. k} without gaps. A template call with for example an undefined parameter 1 and a defined parameter 2 is not supported (where an undefined parameter should not be confused with a parameter which is assigned as value the empty string, these are supported)[4]:
{{xpds|2x|3=abc}}
gives:
{{2x|abc}}
→ abcabc
See also
ਸੋਧੋNotes
ਸੋਧੋ- ↑ 1.0 1.1 1.2 1.3 This is done by the system upon invocation of the module, so not programmed in the module or the templates. To circumvent it the module would have to require an input string with pipes between the parameters replaced by a token. This would make it more cumbersome to enter the wikitext for the invocation.
- ↑ There is no explicit way of telling the system that these characters should be considered plain text: if nowiki is used these tags are treated as part of the parameter name of value.
- ↑ nowiki does not work
- ↑ The reason it that at the left side of the output these names are all implicit. The module cannot determine which were written explicitly in the invocation, except when there is a space or newline at the start or end of the value, then the parameter name was implicit. Writing all explicitly would give wrong output, since the righthand side is based on parameters being implicit or explicit (they would be trimmed in the latter case), in accordance with what they were in the invocation of the module. Writing extra pipes would assign the empty string to the undefined parameters in the gaps, which it not the same as them being undefined.