Template:Tlx/doc: Difference between revisions
Jump to navigation
Jump to search
m (iw) |
RogueScholar (talk | contribs) m (Attempt to clear duplicate parameter tracking category) |
||
(51 intermediate revisions by 32 users not shown) | |||
Line 1: | Line 1: | ||
{| style="margin: 1.5em auto; width: fit-content;" | |||
! colspan="2" scope="col" | Wiki markup | |||
! scope="col" | Output | |||
|- | |||
{{ | | style="text-align: right;" | <kbd><nowiki>{{Tlx|Template|first parameter|second|third|…|tenth}}</nowiki></kbd> | ||
| ⇒ | |||
| | | {{Tlx|Template|first parameter|second|third|…|tenth}} | ||
| | |- | ||
| | | style="text-align: right;" | <kbd><nowiki>{{Tlx|first parameter|…|third|tenth}}</nowiki></kbd> | ||
| | | ⇒ | ||
| {{Tlx|Template|first parameter|second|third|…|tenth}} if they might contain an equality sign (<code>=</code>) | |||
|- | |||
| style="text-align: right;" | <kbd><nowiki>{{Tlx|Template|<nowiki>first|second|…|999th</nowiki>}}</nowiki></pre> | |||
< | | ⇒ | ||
| {{Tlx|Template|<nowiki>first|second|…|999th</nowiki>}} (when you need to show more than ten parameters) | |||
{{ | |} | ||
== Purpose and naming == | |||
==Purpose and naming== | [[wikt:mnemonic|Mnemonically]] ''''T'''emplate '''l'''ink e'''x'''panded', after {{Tlx|Tl}}'s ''''T'''emplate '''l'''ink'. | ||
[[ | |||
* | This template takes another template's name and some associated [[wikipedia:Help:Pipe trick|pipe-tricked]] positional parameters (or 'pass parameters'), and displays them as a demonstrative example of how the template could be coded, literally. Its primary use is in instruction and documentation. | ||
* '''''Specifics:''''' Up to ten pass parameters (numbered or nowiki'd keywords) for the specified template are displayed as 'placeholders', and more than ten parameters can be displayed using a coded vertical-bar (<code>&vert;</code>/<code>&verbar;</code>/<code>&#124;</code>/<code>&VerticalLine;…</code>). A keyword parameter can be used with the equality sign HTML entity (<code>&equals;</code>, <code>&#61;</code> or <code><nowiki>{{=}}</nowiki></code> or in nowiki tags: "<nowiki>param=<var>value</var></nowiki>"; see ''[[#Examples|§ Examples]]'' below. | |||
* '''''Exceptions:''''' If the intended template lists numerous parameters, then perhaps this template should really ''not'' be used, and just hardcode the usage with {{Tag|code|content={{Tag|nowiki|style=plain}}}}, for example: {{Tag|code|content={{Tag|nowiki|style=plain|content=<nowiki>{{</nowiki>Template|param1=<var>23</var>|size=<var>250px</var>|<var>otherparams…</var><nowiki>}}</nowiki>}}}}. If a vertical display with parameters on their own lines is desired, this can also be laid out manually in this manner, or more rapidly done with {{Tag|pre}} tags. | |||
: | <hr style="background-color: #a2a9b1; display: block; height: 2px; margin: 1.25em auto; max-width: 75vmax;" /> | ||
* If given no additional parameters except the template name, as in <code><nowiki>{{Tlx|Template name}}</nowiki></code> or <code><nowiki>{{Tlx|1=Template name}}</nowiki></code>, the output is functionally equivalent to the {{Tl|Tl}} macro template: a blue hyperlink nested in [[wikipedia:Bracket#Curly brackets|double braces]] — the same as a user would apply the template (without parameters) — but with a noticably clearer font and more character spacing on most modern browsers. | |||
** Comparing the output of the two templates side-by-side: Tl ⇒ {{Tl|Template}} versus Tlx ⇒ {{Tlx|Template}} | |||
* Comparatively, {{Tlx|Tl}} will not take or display additional parameters, and for minor technical reasons, may be preferred for mere listing and referencing in long pages involving a lot of template expansions. | * Comparatively, {{Tlx|Tl}} will not take or display additional parameters, and for minor technical reasons, may be preferred for mere listing and referencing in long pages involving a lot of template expansions. | ||
* {{Tlx|Tlx}} has a named parameter, {{Para|subst}}, which when set to any value will place the string <code>subst:</code> before the template name, linked to [[wikipedia:Help:Substitution|Help:Substitution]]. This is useful to indicate when a template should be substituted; for example {{Tlx|Tlx|Template|3=subst=y}} will display {{Tlx|Template|subst=y}}. | |||
== Usage == | |||
<kbd>'''{{[[Template:{{BASEPAGENAME}}|{{BASEPAGENAME}}]]}}'''</kbd> is a generalization of {{[[Template:Tl|Tl]]|x}}, et cetera, with arguably more readable output. This depends on the browser, but most of them use too narrow a form of <code>'''{'''</code>, <code>'''|'''</code> and <code>'''}'''</code> in conjunction with hyperlinks tend to be hard to read. | |||
=== Invocation === | |||
:<kbd>{{{{BASEPAGENAME}}|Template name}}</kbd> | |||
:<kbd>{{{{BASEPAGENAME}}|Template name|param}}</kbd> | |||
:<kbd>{{{{BASEPAGENAME}}|Template name|1|2|3|4|5|6|7|8|9|10}}</kbd> | |||
:<kbd>{{{{BASEPAGENAME}}|Template name|1|2|3|4|5|6|7|8|9|10&vert;more}}</kbd> | |||
:<kbd>{{{{BASEPAGENAME}}|Template name|param&equals;<var>value</var>}}</kbd> | |||
''Up to 10 placeholders for parameters of the specified template'' | |||
=== | |||
:< | |||
:< | |||
:< | |||
:< | |||
:< | |||
''Up to | |||
=== Examples === | === Examples === | ||
{ | {| class="wikitable" style="border: 1px solid #000; border-collapse: collapse; margin: 1em auto;" | ||
! scope="col" | Code | |||
! scope="col" | Result | |||
}} | ! scope="col" | Remark | ||
|- | |||
| <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template}}</nowiki></kbd> | |||
| {{Tlx|Template}} || | |||
|- | |||
| <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Abc}}</nowiki></kbd> | |||
| class="plainlinks" | <kbd><nowiki>{{</nowiki>[https://kodi.wiki/index.php?title=Template:Abc Abc]<nowiki>}}</nowiki></kbd> || | |||
|- | |||
|{{ | | <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|ABC}}</nowiki></kbd> | ||
| class="plainlinks" | <kbd><nowiki>{{</nowiki>[https://kodi.wiki/index.php?title=Template:ABC ABC]<nowiki>}}</nowiki></kbd> || | |||
|- | |||
| <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|AbC}}</nowiki></kbd> | |||
| class="plainlinks" | <kbd><nowiki>{{</nowiki>[https://kodi.wiki/index.php?title=Template:AbC AbC]<nowiki>}}</nowiki></kbd> || | |||
|| | |- | ||
|- | | <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template|one}}</nowiki></kbd> | ||
|{{Tlx | | <kbd><nowiki>{{</nowiki>[[Template:Template|Template]]<nowiki>|one}}</nowiki></kbd> || | ||
| | |- | ||
| <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template|one|two}}</nowiki></kbd> | |||
| <kbd><nowiki>{{</nowiki>[[Template:Template|Template]]<nowiki>|one|two}}</nowiki></kbd> || | |||
|{{ | |- | ||
| | | <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template|1|2|3|4|5|6|7|8|9|10}}</nowiki></kbd> | ||
| <kbd><nowiki>{{</nowiki>[[Template:Template|Template]]<nowiki>|1|2|3|4|5|6|7|8|9|10}}</nowiki></kbd> || | |||
|- | |- | ||
|{{Tlx| | | <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template|1|2|3|4|5|6|7|8|9|10|11}}</nowiki></kbd> | ||
|{{ | | <kbd><nowiki>{{</nowiki>[[Template:Template|Template]]<nowiki>|1|2|3|4|5|6|7|8|9|10|…}}</nowiki></kbd> | ||
|| | | Accepts up to ten parameters, then <code>…</code> | ||
|- | |- | ||
|{{Tlx| | | <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template|1|2|3|4|5|6|7|8|9|10&#124;11}}</nowiki></kbd> | ||
| <kbd><nowiki>{{</nowiki>[[Template:Template|Template]]<nowiki>|1|2|3|4|5|6|7|8|9|10|11}}</nowiki></kbd> | |||
| | | But <code>&#124;</code> instead of the pipe character will let you simulate more | ||
|- | |||
| <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template|<nowiki>14|m|ftin|abbr=out|sp=us</nowiki>}}</nowiki></kbd> | |||
| <kbd><nowiki>{{</nowiki>[[Template:Template|Template]]<nowiki>|14|m|ftin|abbr=out|sp=us}}</nowiki></kbd> | |||
|| | | You can also show an unlimited no. of parameters as a single {{Tag|nowiki}} string | ||
|- | |- | ||
|{{Tlx| | | <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template|x=u}}</nowiki></kbd> | ||
| <kbd><nowiki>{{</nowiki>[[Template:Template|Template]]<nowiki>}}</nowiki></kbd> | |||
| | | Trying to show parameters with set values using a normal <code>=</code> won't work | ||
|- | |||
| | | <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template|x&equals;u}}</nowiki></kbd> | ||
| | | <kbd><nowiki>{{</nowiki>[[Template:Template|Template]]<nowiki>|x=u}}</nowiki></kbd> | ||
| However, using the HTML entity for the equality sign (<code>&equals;</code> or <code>&#61;</code>) works just fine for that | |||
|- | |||
| <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template|x{{=}}u}}</nowiki></kbd> | |||
| | | <kbd><nowiki>{{</nowiki>[[Template:Template|Template]]<nowiki>|x=u}}</nowiki></kbd> | ||
|''' | | <code><nowiki>{{=}}</nowiki></code> costs a few more ms of parser time per page load, but is okay too | ||
| | |- | ||
| | | <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template|<nowiki>x=u</nowiki>}}</nowiki></kbd> | ||
| | | <kbd><nowiki>{{</nowiki>[[Template:Template|Template]]<nowiki>|x=u}}</nowiki></kbd> | ||
| Sticky {{Tag|nowiki}} is a little messy, but works all the same | |||
|- | |||
| <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template| |two}}</nowiki></kbd> | |||
| | | <kbd><nowiki>{{</nowiki>[[Template:Template|Template]]<nowiki>|two}}</nowiki></kbd> | ||
| | | Trying to show an empty positional parameter won't work using just a space | ||
| | |- | ||
|{{Tlx | | <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template|2=|3=two}}</nowiki></kbd> | ||
| <kbd><nowiki>{{</nowiki>[[Template:Template|Template]]<nowiki>|two}}</nowiki></kbd> | |||
| | | Setting a named positional parameter to a null value is sneaky, but doesn't work either | ||
|- | |||
| <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template|&nbsp;|two}}</nowiki></kbd> | |||
| | | <kbd><nowiki>{{</nowiki>[[Template:Template|Template]]<nowiki>| |two}}</nowiki></kbd> | ||
| | | But the HTML entity for a non-breaking space (<code>&nbsp;</code>) will get it done | ||
|- | |||
| <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template|&#8288;|two}}</nowiki></kbd> | |||
|{{Tlx| | | <kbd><nowiki>{{</nowiki>[[Template:Template|Template]]<nowiki>|⁠|two}}</nowiki></kbd> | ||
| | | A true WikiNinja™ will always prefer the invisible Word Joiner character (<code>&#8288;</code>) for that, though | ||
|- | |||
|{{ | | <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template|&vert;two}}</nowiki></kbd> | ||
|{{ | | <kbd><nowiki>{{</nowiki>[[Template:Template|Template]]<nowiki>||two}}</nowiki></kbd> | ||
| | | The HTML entity for a pipe (<code>&vert;</code>/<code>&verbar;</code>/<code>&#124;</code>/<code>&VerticalLine;</code>), though a [[wikt:kludge|kludge]], looks okay too | ||
|- | |||
| <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template|{{!}}two}}</nowiki></kbd> | |||
|{{ | | <kbd><nowiki>{{</nowiki>[[Template:Template|Template]]<nowiki>||two}}</nowiki></kbd> | ||
| | | And speaking of kludges, {{Tlx|!}} is much worse, since it costs extra parser time on each page load again | ||
|- | |- | ||
| | | <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template|2=one|two}}</nowiki></kbd> | ||
| <kbd><nowiki>{{</nowiki>[[Template:Template|Template]]<nowiki>|two}}</nowiki></kbd> | |||
| | | If a named and an unnamed positional parameter end up in a knife fight, the last one supplied always wins | ||
|- | |||
| <kbd><nowiki>{{</nowiki>'''Tlx'''<nowiki>|Template|3=two|2=one}}</nowiki></kbd> | |||
|| {{ | | <kbd><nowiki>{{</nowiki>[[Template:Template|Template]]<nowiki>|one|two}}</nowiki></kbd> | ||
| The order they're specified in doesn't matter, positional parameters are shown in numerical order by name | |||
|}<includeonly> | |||
| | |||
| | |||
| | |||
[[Template: | |||
< | |||
< | |||
< | |||
< | |||
< | |||
[[ | |||
[[Category:Wiki templates]]</includeonly> | |||
[[ | |||
</includeonly> |
Latest revision as of 21:49, 13 September 2022
Wiki markup | Output | |
---|---|---|
{{Tlx|Template|first parameter|second|third|…|tenth}} | ⇒ | {{Template|first parameter|second|third|…|tenth}} |
{{Tlx|first parameter|…|third|tenth}} | ⇒ | {{Template|first parameter|second|third|…|tenth}} if they might contain an equality sign (= )
|
{{Tlx|Template|<nowiki>first|second|…|999th</nowiki>}} | ⇒ | {{Template|first|second|…|999th}} (when you need to show more than ten parameters) |
Purpose and naming
Mnemonically 'Template link expanded', after {{Tl}}'s 'Template link'.
This template takes another template's name and some associated pipe-tricked positional parameters (or 'pass parameters'), and displays them as a demonstrative example of how the template could be coded, literally. Its primary use is in instruction and documentation.
- Specifics: Up to ten pass parameters (numbered or nowiki'd keywords) for the specified template are displayed as 'placeholders', and more than ten parameters can be displayed using a coded vertical-bar (
|
/|
/|
/|…
). A keyword parameter can be used with the equality sign HTML entity (=
,=
or{{=}}
or in nowiki tags: "<nowiki>param=value</nowiki>"; see § Examples below. - Exceptions: If the intended template lists numerous parameters, then perhaps this template should really not be used, and just hardcode the usage with
<code>
, for example:<nowiki>...</nowiki>
</code><code>
. If a vertical display with parameters on their own lines is desired, this can also be laid out manually in this manner, or more rapidly done with<nowiki>{{Template|param1=23|size=250px|otherparams…}}</nowiki>
</code><pre>...</pre>
tags.
- If given no additional parameters except the template name, as in
{{Tlx|Template name}}
or{{Tlx|1=Template name}}
, the output is functionally equivalent to the {{Tl}} macro template: a blue hyperlink nested in double braces — the same as a user would apply the template (without parameters) — but with a noticably clearer font and more character spacing on most modern browsers. - Comparatively, {{Tl}} will not take or display additional parameters, and for minor technical reasons, may be preferred for mere listing and referencing in long pages involving a lot of template expansions.
- {{Tlx}} has a named parameter,
|subst=
, which when set to any value will place the stringsubst:
before the template name, linked to Help:Substitution. This is useful to indicate when a template should be substituted; for example {{Tlx|Template|subst=y}} will display {{subst:Template}}.
Usage
{{Tlx}} is a generalization of {{Tl|x}}, et cetera, with arguably more readable output. This depends on the browser, but most of them use too narrow a form of {
, |
and }
in conjunction with hyperlinks tend to be hard to read.
Invocation
- {{Tlx|Template name}}
- {{Tlx|Template name|param}}
- {{Tlx|Template name|1|2|3|4|5|6|7|8|9|10}}
- {{Tlx|Template name|1|2|3|4|5|6|7|8|9|10|more}}
- {{Tlx|Template name|param=value}}
Up to 10 placeholders for parameters of the specified template
Examples
Code | Result | Remark |
---|---|---|
{{Tlx|Template}} | {{Template}} | |
{{Tlx|Abc}} | {{Abc}} | |
{{Tlx|ABC}} | {{ABC}} | |
{{Tlx|AbC}} | {{AbC}} | |
{{Tlx|Template|one}} | {{Template|one}} | |
{{Tlx|Template|one|two}} | {{Template|one|two}} | |
{{Tlx|Template|1|2|3|4|5|6|7|8|9|10}} | {{Template|1|2|3|4|5|6|7|8|9|10}} | |
{{Tlx|Template|1|2|3|4|5|6|7|8|9|10|11}} | {{Template|1|2|3|4|5|6|7|8|9|10|…}} | Accepts up to ten parameters, then …
|
{{Tlx|Template|1|2|3|4|5|6|7|8|9|10|11}} | {{Template|1|2|3|4|5|6|7|8|9|10|11}} | But | instead of the pipe character will let you simulate more
|
{{Tlx|Template|<nowiki>14|m|ftin|abbr=out|sp=us</nowiki>}} | {{Template|14|m|ftin|abbr=out|sp=us}} | You can also show an unlimited no. of parameters as a single <nowiki>...</nowiki> string
|
{{Tlx|Template|x=u}} | {{Template}} | Trying to show parameters with set values using a normal = won't work
|
{{Tlx|Template|x=u}} | {{Template|x=u}} | However, using the HTML entity for the equality sign (= or = ) works just fine for that
|
{{Tlx|Template|x{{=}}u}} | {{Template|x=u}} | {{=}} costs a few more ms of parser time per page load, but is okay too
|
{{Tlx|Template|<nowiki>x=u</nowiki>}} | {{Template|x=u}} | Sticky <nowiki>...</nowiki> is a little messy, but works all the same
|
{{Tlx|Template| |two}} | {{Template|two}} | Trying to show an empty positional parameter won't work using just a space |
{{Tlx|Template|2=|3=two}} | {{Template|two}} | Setting a named positional parameter to a null value is sneaky, but doesn't work either |
{{Tlx|Template| |two}} | {{Template| |two}} | But the HTML entity for a non-breaking space ( ) will get it done
|
{{Tlx|Template|⁠|two}} | {{Template||two}} | A true WikiNinja™ will always prefer the invisible Word Joiner character (⁠ ) for that, though
|
{{Tlx|Template||two}} | {{Template||two}} | The HTML entity for a pipe (| /| /| /| ), though a kludge, looks okay too
|
{{Tlx|Template|{{!}}two}} | {{Template||two}} | And speaking of kludges, {{!}} is much worse, since it costs extra parser time on each page load again |
{{Tlx|Template|2=one|two}} | {{Template|two}} | If a named and an unnamed positional parameter end up in a knife fight, the last one supplied always wins |
{{Tlx|Template|3=two|2=one}} | {{Template|one|two}} | The order they're specified in doesn't matter, positional parameters are shown in numerical order by name |