Template:Xpd

From TrainzOnline
Jump to: navigation, search



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| }}}} || {{tc{{#if:|{{{{{1n}}}}}}}{{#ifeq:+|-|||||{{#ifeq:-|+||||{{#ifeq:-|+|||}}}}}}}} gives {{#ifeq:-|+|Template:Tc|{{#ifeq:-|+|Template:Tc|{{#ifeq:-|+|Template:Tc|Template:Tc}}}}}}

}}xpd{{#if:CURRENTDAY|

| CURRENTDAY }}{{#if:| | {{{3}}} }}{{#if:| | {{{4}}} }}{{#if:| | {{{5}}} }}{{#if:| | ... }}{{#if:CURRENTDAY| }}}} || {{CURRENTDAY{{#if:|{{{{{1n}}}}}}}{{#ifeq:+|-|||||{{#ifeq:-|+||||{{#ifeq:-|+|||}}}}}}}} gives {{#ifeq:-|+|Template:CURRENTDAY|{{#ifeq:-|+|Template:CURRENTDAY|{{#ifeq:-|+|Template:CURRENTDAY|26}}}}}}

}}xpd{{#if:#expr:2*3|

| #expr:2*3 }}{{#if:| | {{{3}}} }}{{#if:| | {{{4}}} }}{{#if:| | {{{5}}} }}{{#if:| | ... }}{{#if:#expr:2*3| }}}} || {{#expr:2*3{{#if:|{{{{{1n}}}}}}}{{#ifeq:+|-|||||{{#ifeq:-|+||||{{#ifeq:-|+|||}}}}}}}} gives {{#ifeq:-|+|{{#expr:2*3|||}}|{{#ifeq:-|+|{{#expr:2*3||}}|{{#ifeq:-|+|{{#expr:2*3|}}|{{#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| }}}} || {{#expr:2+2=5{{#if:|{{{{{1n}}}}}}}{{#ifeq:+|-|||||{{#ifeq:-|+||||{{#ifeq:-|+|||}}}}}}}} gives {{#ifeq:-|+|{{#expr:2+2=5|||}}|{{#ifeq:-|+|{{#expr:2+2=5||}}|{{#ifeq:-|+|{{#expr:2+2=5|}}|{{#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| }}}} || {{#expr:2+2=4{{#if:|{{{{{1n}}}}}}}{{#ifeq:+|-|||||{{#ifeq:-|+||||{{#ifeq:-|+|||}}}}}}}} gives {{#ifeq:-|+|{{#expr:2+2=4|||}}|{{#ifeq:-|+|{{#expr:2+2=4||}}|{{#ifeq:-|+|{{#expr:2+2=4|}}|{{#expr:2+2=4}}}}}}}}

}}xpd{{#if:urlencode:!|

| urlencode:! }}{{#if:| | {{{3}}} }}{{#if:| | {{{4}}} }}{{#if:| | {{{5}}} }}{{#if:| | ... }}{{#if:urlencode:!| }}}} || {{urlencode:!{{#if:|{{{{{1n}}}}}}}{{#ifeq:+|-|||||{{#ifeq:-|+||||{{#ifeq:-|+|||}}}}}}}} gives {{#ifeq:-|+|%21|{{#ifeq:-|+|%21|{{#ifeq:-|+|%21|%21}}}}}}

}}xpd{{#if:uc:abc|

| uc:abc }}{{#if:| | {{{3}}} }}{{#if:| | {{{4}}} }}{{#if:| | {{{5}}} }}{{#if:| | ... }}{{#if:uc:abc| }}}} || {{uc:abc{{#if:|{{{{{1n}}}}}}}{{#ifeq:+|-|||||{{#ifeq:-|+||||{{#ifeq:-|+|||}}}}}}}} gives {{#ifeq:-|+|ABC|{{#ifeq:-|+|ABC|{{#ifeq:-|+|ABC|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*| }}}} || {{#expr:24*{{CURRENTDAY}}}} {{#ifeq: +|-|{{{s}}}|gives}} {{#expr:24*26}}

}}xpdn{{#if:#expr:24*|

| #expr:24* }}{{#if:CURRENTDAY| | CURRENTDAY }}{{#if:-24| | -24 }}{{#if:| | {{{5}}} }}{{#if:| | ... }}{{#if:#expr:24*| }}}} || {{#expr:24*{{CURRENTDAY}}-24}} {{#ifeq: +|-|{{{s}}}|gives}} {{#expr:24*26-24}}

}}xpdn{{#if:#expr:4*|

| #expr:4* }}{{#if:#expr:not 0| | #expr:not 0 }}{{#if: >3| | >3 }}{{#if:| | {{{5}}} }}{{#if:| | ... }}{{#if:#expr:4*| }}}} || {{#expr: 4*{{#expr:not 0}} >3}} {{#ifeq: +|-|{{{s}}}|gives}} {{#expr: 4*{{#expr:not 0}} >3}}

}}xpdn{{#if:urlencode:|

| urlencode: }}{{#if:DIRMARK| | DIRMARK }}{{#if:| | {{{4}}} }}{{#if:| | {{{5}}} }}{{#if:| | ... }}{{#if:urlencode:| }}}} || {{urlencode:{{DIRMARK}}}} {{#ifeq: +|-|{{{s}}}|gives}} %E2%80%8E

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| }}}} || {{#ifeq: 1.00{{#if:|{{{{{1n}}}}}}}{{#ifeq:+|-||+1|okay||{{#ifeq:okay|okay||+1|okay|{{#ifeq:+1|+1||+1|}}}}}}}} gives {{#ifeq:-|+|{{#ifeq: 1.00|+1|okay|}}|{{#ifeq:okay|okay|{{#ifeq: 1.00|+1|okay}}|{{#ifeq:+1|+1|{{#ifeq: 1.00|+1}}|{{#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> || {{#ifeq: this{{#if:|{{{{{1n}}}}}}}{{#ifeq:false|false||that||false|{{#ifeq:|||that||{{#ifeq:that|that||that|}}}}}}}} is {{#ifeq:false|false|{{#ifeq: this|that||false}}|{{#ifeq:||{{#ifeq: this|that|}}|{{#ifeq:that|that|{{#ifeq: this|that}}|{{#ifeq: this}}}}}}}}

}}xpd{{#if:t|

| t }}{{#if:b| | b }}{{#if:| | {{{4}}} }}{{#if:| | {{{5}}} }}{{#if:| | ... }}{{#if:t| }}}} || {{t{{#if:|{{{{{1n}}}}}}}{{#ifeq:+|-||b|||{{#ifeq:-|+||b||{{#ifeq:b|b||b|}}}}}}}} gives {{#ifeq:-|+|Template:T|{{#ifeq:-|+|Template:T|{{#ifeq:b|b|Template:T|Template:T}}}}}}

}}xpd{{#if:t2|

| t2 }}{{#if:b| | b }}{{#if:c| | c }}{{#if:| | {{{5}}} }}{{#if:| | ... }}{{#if:t2| }}}} || {{t2{{#if:|{{{{{1n}}}}}}}{{#ifeq:+|-||b|c||{{#ifeq:c|c||b|c|{{#ifeq:b|b||b|}}}}}}}} gives {{#ifeq:-|+|Template:T2|{{#ifeq:c|c|Template:T2|{{#ifeq:b|b|Template:T2|Template: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| }}}} || {{CURRENTDAY{{#if:|{{{{{1n}}}}}}}{{#ifeq:+|-|||||{{#ifeq:-|+||||{{#ifeq:-|+|||}}}}}}}} is {{#ifeq:-|+|Template:CURRENTDAY|{{#ifeq:-|+|Template:CURRENTDAY|{{#ifeq:-|+|Template:CURRENTDAY|26}}}}}}

}}xpd{{#if:1=#expr:2+2|

| 1=#expr:2+2 }}{{#if:s==| | s== }}{{#if:| | {{{4}}} }}{{#if:| | {{{5}}} }}{{#if:| | ... }}{{#if:1=#expr:2+2| }}}} || {{#expr:2+2{{#if:|{{{{{1n}}}}}}}{{#ifeq:+|-|||||{{#ifeq:-|+||||{{#ifeq:-|+|||}}}}}}}} = {{#ifeq:-|+|{{#expr:2+2|||}}|{{#ifeq:-|+|{{#expr:2+2||}}|{{#ifeq:-|+|{{#expr:2+2|}}|{{#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*| }}}} || {{#expr: 4*{{#expr:not 0}} >3 }} {{#ifeq: +|-|{{{s}}}| yields}} {{#expr: 4*{{#expr:not 0}} >3 }}

See also


Contents

 

Personal tools