Šablonas:xpd/doc

Puslapis iš Vikižodyno, laisvojo žodyno.
Šį puslapį sudaro dokumentacija, kategorijos ir kita informacija, kuri nėra šablono dalis.
Norint peržiūrėti pati šablonas puslapį, žr. Šablonas:xpd.

Šablonas:hh Šablonas:sspp This template:xpd ( aptarimas redaguoti istorija nuorodos ) (expansion demo) shows the call of a variable, parser function or template and its result, for documentation. It works with unnamed parameters only.

Usage:
Šablonas:Tlx

Please note that for parser functions the first parameter belongs to the left side before "|".

Examples without additional parameters:

Šablonas:Tlx Šablonas:xpd0
Šablonas:Tlx Šablonas:xpd0
Šablonas:Tlx Šablonas:xpd0
Šablonas:Tlx Šablonas:xpd0
Šablonas:Tlx Šablonas:xpd0
Šablonas:Tlx Šablonas:xpd0
Šablonas:Tlx Šablonas:xpd0

{{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 ( aptarimas redaguoti istorija nuorodos ) 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 "}}".

Šablonas:Tlx Šablonas:xpdn
Šablonas:Tlx Šablonas:xpdn
Šablonas:Tlx Šablonas:xpdn
Šablonas:Tlx Šablonas:xpdn

Examples with additional parameters (no nesting possible):

Šablonas:Tlx {{#ifeq: 1.00|+1|okay}} gives okay
Šablonas:Tlx Šablonas:xpd3
Šablonas:Tlx {{t|b}} gives (tarm.| b) [1]
Šablonas:Tlx {{t2|b|c}} gives c

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|wikt=abc|}} gives Šablonas: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[taisyti]

Usage:
Šablonas:Tlx
Šablonas:Tlx
The default separator is "gives", use s== or similar to get "=" etc.

Examples with separator parameter:

Šablonas:Tlx Šablonas:xpd0
Šablonas:Tlx Šablonas:xpd0
Šablonas:Tlx Šablonas:xpdn

Limitations[taisyti]

Named parameters[taisyti]

Named parameters are not supported. Neither are equals signs in parameter values.

{{xpd|t np|q=s}} gives: Šablonas:xpd0 ("q=s" is ignored)

{{xpd|t np|2=q=s}} gives: {{t np|q=s}} gives p{{{q}}}r [2] (wrong result)

Actually:

  • {{t np|1=q=s}} gives p{{{q}}}r [3]
  • {{t np|q=s}} gives psr [4]

Rendering of left side[taisyti]

The left-hand side, before "gives", does not show the literal wikitext of the parameters of the template or parser function demonstrated, but the rendering. This affects e.g. sequences of more than two spaces, and single newlines. Also link code is shown as a link. Furthermore, any templates and parser functions in the parameters are expanded; template:xpdn ( aptarimas redaguoti istorija nuorodos ) covers the simpler of such cases.

Examples:


{{xpd|1x|[[Help:L{{tc}}k]]}}

{{xpd|t1|p
q}}

gives:


{{1x|Help:Link}} gives Help:Link [5]

{{t1|p q}} gives startp qend [6]


With substitution of xpd1 etc. (see below) and putting nowiki tags around the list of parameters the left hand side is corrected.

Spaces and newlines[taisyti]

If parameters start or end with a space or newline, these are preserved. Although the left-hand side, as mentioned, does not show the raw wikitext of the parameters but the rendering, the right-hand side gives the correct result.

Example with two newlines, hence also the left-hand side is correct:

Šablonas:xpdc


Example without consecutive spaces inside a parameter value, hence also the left-hand side is correct:

"Šablonas:xpdc"

Substitution[taisyti]

  • {{subst:xpd|substnp=subst:|tc}} gives the wikitext {{xpd0|tc}}
  • {{subst:xpd|substnp=subst:|t1|p}} gives the wikitext {{xpd1|t1|p}}
  • {{subst:xpd|substnp=subst:|t2|p|q}} gives the wikitext {{xpd2|t2|p|q}}
  • {{subst:xpd|substnp=subst:|concat|p|q|r}} gives the wikitext {{xpd3|concat|p|q|r}}

Note that except in the case of long and complicated parameters, adding the number of parameters after "xpd" is easier than adding "subst:" and "|substnp=subst:".

With substitution of xpd1 etc. and putting nowiki tags around the list of parameters the left hand side is given literally without conversions, see also above.

See also[taisyti]