Skabelon:Xpd
"{{{{{1}}}}}" gives "{{{{{1}}}}}" [1]
The expansion demo templates (see [2]) show, for documentation:
- some wikitext
- its rendering
- a link to ExpandTemplates applied to the wikitext; thus it shows:
- The expanded wikitext.
- The rendering of this expanded wikitext
Skabelon:xpd (backlinks redigér) selects one of the following four templates based on the number of unnamed parameters
- Skabelon:xpd0 (backlinks redigér) - simplified version of m:Template:xpdoc (backlinks redigér)
- Skabelon:xpd1 (backlinks redigér) - simplified version of m:Template:xpdopec (backlinks redigér)
- Skabelon:xpd2 (backlinks redigér) - simplified version of m:Template:xpdopepec (backlinks redigér)
- Skabelon:xpd3 (backlinks redigér) - simplified version of m:Template:xpdopepepec (backlinks redigér)
Examples
{{xpd|CURRENTDAY}} gives:
"{{CURRENTDAY}}" gives "22" [3]
{{xpd|#expr:2+2}} gives:
"{{#expr:2+2}}" gives "4" [4]
For more examples see the separate templates.
Separator parameter
The default separator is "gives". With gives={{!}}{{!}} to get "||" for use in a table, the same separator is used before the ExpandTemplates link.
Example:
{| class="wikitable"
!wikitext!!result!!ExpandTemplates
|-
|{{xpd|CURRENTDAY|gives={{!}}{{!}}}}
|-
|{{xpd|#expr:2+2|gives={{!}}{{!}}}}
|}
gives
| wikitext | result | ExpandTemplates |
|---|---|---|
"{{CURRENTDAY}}" |
"22" | [5] |
"{{#expr:2+2}}" |
"4" | [6] |
Quotes
The quotation marks are needed to see spaces and newlines at the start and end of the result. In other expand demo templates they are also needed to see spaces and newlines at the start and end of the wikitext, and to get a result independent of whether it starts on a line due to parameter {{{gives}}}.
Limitations
This Template:Xpd is a simplified version of some expansion demo templates. If necessary use the proper extended version.
Named parameters and parameter values with equals signs
Named parameters are not supported. Neither are equals signs in parameter values of the template or parser function demonstrated.
Examples:
- {{xpd|1x| p{{=}}q }} gives
"{{1x|p=q}}"gives " p=q " [7] - wrong result due to the template call in the parameter; is corrected by substitution and putting nowiki tags in the lefthand side (see below), giving {{1x| p{{=}}q}} gives p=q [8]. - {{xpd|1x|2= p=q }} gives
"{{1x|p=q}}"gives "p=q" [9] - wrong result because the lefthand side would be expanded interpreting p as named parameter, while the righthand side shows the result if the unnamed parameter of 1x has the given value; use {{xpdopec|1x|1|3= p=q }} giving"{{1x|1=p=q}}"gives "p=q" [10] or {{xpdnp|1x|1n=1|1v= p=q }} giving Skabelon:Xpdnp (spaces and newlines are trimmed). - {{xpd|t np|q=s}} gives:
"{{t np}}"gives "Skabelon:T np" [11] ("q=s" is ignored); instead, use {{xpdopec|t np|q|s}} giving"{{t np|q=s}}"gives "Skabelon:T np" [12] or {{xpdnp|t np|1n=q|1v=s}} giving Skabelon:Xpdnp.
Even in the case of a parser function called with a parameter containing an equals sign the template for named parameters should be used:
- {{xpd|#if:x|p=q}} gives:
"{{#if:x}}"gives "" [13] ("p=q" is ignored); instead, use {{xpdnp|#if:x|1n=p|1v=q}} giving Skabelon:Xpdnp.
Rendering of left side
If no value for parameter p is given, 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; m:Template:xpdn (backlinks redigér) covers the simpler of such cases.
Examples:
{{xpd|1x|[[Help:Link]]}}
{{xpd|tl|p
q}}
gives:
"{{1x|[[Hjælp:Link]]}}" gives "Hjælp:Link" [14]
"{{tl|p
q}}" gives "{{[[Skabelon:p
q|p
q]]}}" [15]
With substitution of xpd1 etc. (see below) and putting nowiki tags around the list of parameters the left hand side is corrected.
Also the input text of ExpandTemplates in the supplied link is the result of expanding the parameters.
Spaces and newlines
If parameters start or end with a space or newline, these are preserved. Even if 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.
Substitution
- {{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
- Skabelon:xpsoc (backlinks redigér) - simplified version
- Skabelon:xpd0 (backlinks redigér) - simplified version of m:Template:xpdoc (backlinks redigér)
- Skabelon:xpd1 (backlinks redigér) - simplified version of m:Template:xpdopec (backlinks redigér)
- Skabelon:xpd2 (backlinks redigér) - simplified version of m:Template:xpdopepec (backlinks redigér)
- Skabelon:xpd3 (backlinks redigér) - simplified version of m:Template:xpdopepepec (backlinks redigér)
- m:Template:xpdt1 (backlinks redigér) for table row templates
- m:Template:xpdnp (backlinks redigér) for named parameters
- Xpd templates
- m:Template:tlx (backlinks redigér) - produces just the template call, with the template name linked to the template, but not the result, e.g.
"{{tlx|t2|b|c}}"gives "{{t2|b|c}}" [16]
Undocumented (so far):
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.









