Template:Xpd
This Template:xpd (expansion demo) shows the call of a variable, parser function or template and its result, for documentation.
- Usage:
- {{{{#if:left side| }}xpd{{#if:left side|
| left side }}{{#if:up to 3 additional parameters| | </tt>up to 3 additional parameters }}{{#if:| | {{{4}}} }}{{#if:| | {{{5}}} }}{{#if:| | ... }}{{#if:left side| }}}}</tt>
Please note that for parser functions the first parameter belongs to the left side before "|".
Examples without additional parameters:
}}xpd{{#if:tc|
| tc
}}{{#if:|
| {{{3}}}
}}{{#if:|
| {{{4}}}
}}{{#if:|
| {{{5}}}
}}{{#if:|
| ...
}}{{#if:tc| }}}} || {{ |
}}xpd{{#if:CURRENTDAY|
| CURRENTDAY
}}{{#if:|
| {{{3}}}
}}{{#if:|
| {{{4}}}
}}{{#if:|
| {{{5}}}
}}{{#if:|
| ...
}}{{#if:CURRENTDAY| }}}} || {{ |
}}xpd{{#if:#expr:2*3|
| #expr:2*3
}}{{#if:|
| {{{3}}}
}}{{#if:|
| {{{4}}}
}}{{#if:|
| {{{5}}}
}}{{#if:|
| ...
}}{{#if:#expr:2*3| }}}} || {{ |
}}xpd{{#if:1=#expr:2+2=5|
| 1=#expr:2+2=5
}}{{#if:|
| {{{3}}}
}}{{#if:|
| {{{4}}}
}}{{#if:|
| {{{5}}}
}}{{#if:|
| ...
}}{{#if:1=#expr:2+2=5| }}}} || {{ |
}}xpd{{#if:1=#expr:2+2=4|
| 1=#expr:2+2=4
}}{{#if:|
| {{{3}}}
}}{{#if:|
| {{{4}}}
}}{{#if:|
| {{{5}}}
}}{{#if:|
| ...
}}{{#if:1=#expr:2+2=4| }}}} || {{ |
}}xpd{{#if:urlencode:!|
| urlencode:!
}}{{#if:|
| {{{3}}}
}}{{#if:|
| {{{4}}}
}}{{#if:|
| {{{5}}}
}}{{#if:|
| ...
}}{{#if:urlencode:!| }}}} || {{ |
}}xpd{{#if:uc:abc|
| uc:abc
}}{{#if:|
| {{{3}}}
}}{{#if:|
| {{{4}}}
}}{{#if:|
| {{{5}}}
}}{{#if:|
| ...
}}{{#if:uc:abc| }}}} || {{ |
{{subst:xpd|uc:Upper Case|subst=subst:}} substitutes {{ subst:uc:Upper Case
}} gives UPPER CASE
See Help:Substitution for several caveats wrt subst=subst:.
Note that, as always, a parameter containing "=" has to be explicitly named by putting, in this case, "1=" in front.
Template:Xpdn can be used in the case of an expression in double braces which itself includes a pair of double braces (simple nested expressions). Use "|" for the inner "{{" and, if there is code after it, also for "}}".
}}xpdn{{#if:#expr:24*|
| #expr:24*
}}{{#if:CURRENTDAY|
| CURRENTDAY
}}{{#if:|
| {{{4}}}
}}{{#if:|
| {{{5}}}
}}{{#if:|
| ...
}}{{#if:#expr:24*| }}}} || {{ |
}}xpdn{{#if:#expr:24*|
| #expr:24*
}}{{#if:CURRENTDAY|
| CURRENTDAY
}}{{#if:-24|
| -24
}}{{#if:|
| {{{5}}}
}}{{#if:|
| ...
}}{{#if:#expr:24*| }}}} || {{ |
}}xpdn{{#if:#expr:4*|
| #expr:4*
}}{{#if:#expr:not 0|
| #expr:not 0
}}{{#if: >3|
| >3
}}{{#if:|
| {{{5}}}
}}{{#if:|
| ...
}}{{#if:#expr:4*| }}}} || {{ |
}}xpdn{{#if:urlencode:|
| urlencode:
}}{{#if:DIRMARK|
| DIRMARK
}}{{#if:|
| {{{4}}}
}}{{#if:|
| {{{5}}}
}}{{#if:|
| ...
}}{{#if:urlencode:| }}}} || {{ |
Examples with additional parameters (no nesting possible):
}}xpd{{#if:#ifeq: 1.00|
| #ifeq: 1.00
}}{{#if:+1|
| +1
}}{{#if:okay|
| okay
}}{{#if:|
| {{{5}}}
}}{{#if:|
| ...
}}{{#if:#ifeq: 1.00| }}}} || {{ |
}}xpd{{#if:#ifeq: this|
| #ifeq: this
}}{{#if:that<tt>||false|
| that||false
}}{{#if:s=is|
| s=is
}}{{#if:|
| {{{5}}}
}}{{#if:|
| ...
}}{{#if:#ifeq: this| }}}}</tt> || {{ |
}}xpd{{#if:t|
| t
}}{{#if:b|
| b
}}{{#if:|
| {{{4}}}
}}{{#if:|
| {{{5}}}
}}{{#if:|
| ...
}}{{#if:t| }}}} || {{ |
}}xpd{{#if:t2|
| t2
}}{{#if:b|
| b
}}{{#if:c|
| c
}}{{#if:|
| {{{5}}}
}}{{#if:|
| ...
}}{{#if:t2| }}}} || {{ |
In the case of one or more named parameters, write all parameter definitions from that as value of the appropriate parameter number, e.g.:
- {{xpd|t link|2=wikt=abc|3=}} gives "{{
t link{{#if:|
{{{{{1n}}}
}}}}{{#ifeq:+|-||wikt=abc|||{{#ifeq:|||wikt=abc||{{#ifeq:wikt=abc|wikt=abc||wikt=abc|}}}}}}
}} gives {{#ifeq:-|+|Template:T link|{{#ifeq:||Template:T link|{{#ifeq:wikt=abc|wikt=abc|Template:T link|Template:T link}}}}}}"
Optional substitution with subst=subst: is not supported. The demo template shows what another template actually does, and not what it did some time ago.
Separator parameter
- Usage:
- {{{{#if:left side| }}xpd{{#if:left side|
| left side }}{{#if:up to 3 additional parameters| | </tt>up to 3 additional parameters }}{{#if:s=separator| | s=separator }}{{#if:| | {{{5}}} }}{{#if:| | ... }}{{#if:left side| }}}}</tt>
- {{{{#if:left side| }}xpdn{{#if:left side|
| left side }}{{#if:nested part and optional last part| | </tt>nested part and optional last part }}{{#if:s=separator| | s=separator }}{{#if:| | {{{5}}} }}{{#if:| | ... }}{{#if:left side| }}}}</tt>
- The default separator is "gives", use s== or similar to get "=" etc.
Examples with separator parameter:
}}xpd{{#if:CURRENTDAY|
| CURRENTDAY
}}{{#if:s=is|
| s=is
}}{{#if:|
| {{{4}}}
}}{{#if:|
| {{{5}}}
}}{{#if:|
| ...
}}{{#if:CURRENTDAY| }}}} || {{ |
}}xpd{{#if:1=#expr:2+2|
| 1=#expr:2+2
}}{{#if:s==|
| s==
}}{{#if:|
| {{{4}}}
}}{{#if:|
| {{{5}}}
}}{{#if:|
| ...
}}{{#if:1=#expr:2+2| }}}} || {{ |
}}xpdn{{#if:#expr:4*|
| #expr:4*
}}{{#if:#expr:not 0|
| #expr:not 0
}}{{#if: >3 | yields|
| >3 | yields
}}{{#if:|
| {{{5}}}
}}{{#if:|
| ...
}}{{#if:#expr:4*| }}}} || {{ |
See also
|