Teamplaid:Xpd/documentation
This is a documentation subpage for Teamplaid:Xpd. It contains usage information, categories and other content that is not part of the original teamplaid page. |
The expansion demo templates (see Special:All pages with prefix (Template namespace)) 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
Teamplaid:Xpd (ceanglaichean deasaich) selects one of the following four templates based on the number of unnamed parameters
- Teamplaid:Xpd0 (ceanglaichean deasaich) - simplified version of m:Template:Xpdoc (backlinks edit)
- Teamplaid:Xpd1 (ceanglaichean deasaich) - simplified version of m:Template:Xpdopec (backlinks edit)
- Teamplaid:Xpd2 (ceanglaichean deasaich) - simplified version of m:Template:Xpdopepec (backlinks edit)
- Teamplaid:Xpd3 (ceanglaichean deasaich) - simplified version of m:Template:Xpdopepepec (backlinks edit)
Eisimpleirean - Examples
deasaich{{Xpd|CURRENTDAY}} gives:
"{{CURRENTDAY}}"
gives "17" [1]
{{Xpd|#expr:2+2}} gives:
"{{#expr:2+2}}"
gives "4" [2]
For more examples see the separate templates.
Separator parameter
deasaichThe 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}}" |
"17" | [3] |
"{{#expr:2+2}}" |
"4" | [4] |
Quotes
deasaichThe 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
deasaichThis 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
deasaichNamed 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 " [5] - 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 [6]. - {{Xpd|1x|2= p=q }} gives
"{{1x|p=q}}"
gives "p=q" [7] - 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" [8] or {{Xpdnp|1x|1n=1|1v= p=q }} giving Teamplaid:Xpdnp (spaces and newlines are trimmed).
" - {{Xpd|T np|q=s}} gives:
"{{T np}}"
gives "Teamplaid:T np" [9] ("q=s" is ignored); instead, use {{Xpdopec|T np|q|s}} giving"{{T np|q=s}}
gives "Teamplaid:T np" [10] or {{Xpdnp|T np|1n=q|1v=s}} giving Teamplaid: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 "" [11] ("p=q" is ignored); instead, use {{Xpdnp|#if:x|1n=p|1v=q}} giving Teamplaid:Xpdnp.
Rendering of left side
deasaichIf 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 edit) covers the simpler of such cases.
Eisimpleirean - Examples
deasaich{{Xpd|1x|[[:en:w:Help:Link|Help:Link]]}} {{Xpd|Tl|p q}}
gives:
"{{1x|[[:en:w:Help:Link|Help:Link]]}}"
gives "Help:Link" [12]
"{{Tl|p
q}}"
gives "{{[[Teamplaid:p
q|p
q]]}}" [13]
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
deasaichIf 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
deasaich- {{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.
Faic cuideachd - Also see
- Teamplaid:Demo (ceanglaichean deasaich) - a more robust and flexible template with the same functionality
- Teamplaid:Xpsoc (ceanglaichean deasaich) - simplified version
- Teamplaid:Xpd0 (ceanglaichean deasaich) - simplified version of m:Template:Xpdoc (backlinks edit)
- Teamplaid:Xpd1 (ceanglaichean deasaich) - simplified version of m:Template:Xpdopec (backlinks edit)
- Teamplaid:Xpd2 (ceanglaichean deasaich) - simplified version of m:Template:Xpdopepec (backlinks edit)
- Teamplaid:Xpd3 (ceanglaichean deasaich) - simplified version of m:Template:Xpdopepepec (backlinks edit)
- m:Template:Xpdt1 (backlinks edit) for table row templates
- m:Template:Xpdnp (backlinks edit) for named parameters
- Xpd templates
- m:Template:Tlx (backlinks edit) - 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}}" [14]
Undocumented (so far):
- Teamplaid:Xpda (ceanglaichean deasaich)
- Teamplaid:Xpdop3c (ceanglaichean deasaich)
- Teamplaid:Xpdop3p3c (ceanglaichean deasaich)
Other formatting templates
deasaichCode example | Effect | Notes |
---|---|---|
{{Tl2|Hatnote|lang=fr}} | {{Hatnote}} | Supports linking to sister projects (e.g., fr:Hatnote) |
{{Tlu|User:Ahunt/SSHFS}} | {{User:Ahunt/SSHFS}} | Supports linking to any namespace |
{{Demo|<nowiki> </nowiki>}} | {{Hatnote|lang=fr|Some text}} |
Shows code and example |
{{Xpd|Hatnote|Some Hatnote text}} | "{{Hatnote|Some Hatnote text}}" gives " " [15] |
Shows code, example and a link to expand the template code |
{{Tln|Hatnote}} | Template:Hatnote | Produces a normal link to the template |
{{Elc|Template:Hatnote}} {{Elc|Template:Hatnote|Hatnote}} |
[[Template:Hatnote]] [[Template:Hatnote|Hatnote]] |
Formats wikilink, with optional piped link text and blended suffix |
{{Ml|Example|hello}} | {{#invoke:Example|hello}} | Counterpart to {{Tl}} for linking to Lua modules |
{{Mlx|Example|hello}} | {{#invoke:Example|hello}} |
Counterpart to {{Tlx}} for linking to Lua modules |
{{Para|title|<var>book title</var>}} | title=book title | Formats template parameters for display, with or without values |
{{Sclx|LASTING}} | [[w:en:WP:LASTING]] |
Takes a shortcut suffix in project namespace and displays it with brackets and the WP: alias in a <code>...</code> Tag.
|
{{Tag|ref}} {{Xtag|templatedata}} |
<ref>...</ref> <templatedata> |
Formats [X]HTML tags; can add content, choose opening, closing, or self-closing |
{{Dtl|Ping project}} | {{d:Ping project}} | Wikidata counterpart to {{Tl}} |
{{Pf|If}} {{Pf|If|Other formatting templates|true|false}} |
{{#If}} {{#If:{{{1}}}|true|false}} |
Parser function equivalent to {{Tl}} |