Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:Tlx/doc: Difference between revisions

Template page
mNo edit summary
m code instead of tt tag
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{documentation subpage}}
This template creates example usage syntax for a template, and links the name to the template page. The name is derived from "'''T'''emplate '''l'''ist e'''x'''panded".


This is the {{tl|tlx}} or '''t'''emplate '''l'''ink e'''x'''panded template.
Up to 7 pass parameters (numbered) for the specified template are displayed as 'placeholders', and more parameters are shown as "<code>|</code>''...''". An optional <code>SISTER</code> parameter can specify an interwiki prefix to link to another wiki. Examples:


It can be used in documentation and talk page discussions to show how a template name would be used in code.
{| border="1" cellpadding="4" class="wikitable"
! Code
! Result
! Remark
|-
|{{Tlx|SISTER=W:|Tlx|x0}}
|{{Tlx|SISTER=W:|x0}}
||&#160;
|-
|{{Tlx|SISTER=W:|Tlx|x1|one}}
|{{Tlx|SISTER=W:|x1|one}}
||&#160;
|-
|{{Tlx|SISTER=W:|Tlx|x2|one|two}}
|{{Tlx|SISTER=W:|x2|one|two}}
||&#160;
|-
|{{Tlx|SISTER=W:|Tlx|x3|1<code>&#124;</code>2<code>&#124;</code>3}}
|{{Tlx|SISTER=W:|x3|1|2|3}}
||&#160;
|-
|{{Tlx|SISTER=W:|Tlx|x4|1<code>&#124;</code>2<code>&#124;</code>3|4}}
|{{Tlx|SISTER=W:|x4|1|2|3|4}}
|up to 7 parameters, then ...
|-
|{{Tlx|SISTER=W:|Tlx|x4|1<code>&#124;</code>2<code>&#124;</code>3&amp;#124;4}}
|{{Tlx|SISTER=W:|x4|1|2|3&#124;4}}
|align="right"|<code>&amp;#124;</code> for more
|-
|{{Tlx|SISTER=W:|Tlx|x1|x&#61;u}}
|{{Tlx|SISTER=W:|x1|x=u}}
|'''=''' won't work
|-
|{{Tlx|SISTER=W:|Tlx|x1|x&amp;#61;u}}
|{{Tlx|SISTER=W:|x1|x&#61;u}}
|align="right"|<code>&amp;#61;</code> is okay
|-
|{{Tlx|SISTER=W:|Tlx|x1|&lt;nowiki&gt;x&#61;u&lt;/nowiki&gt;}}
|{{Tlx|SISTER=W:|x1|<nowiki>x=u</nowiki>}}
|align="right"|sticky nowiki is okay
|-
|{{Tlx|SISTER=W:|Tlx|x2|&#160;|two}}
|{{Tlx|SISTER=W:|x2| |two}}
|empty won't work
|-
|{{Tlx|SISTER=W:|Tlx|x2|&amp;#32;|two}}
|{{Tlx|SISTER=W:|x2|&#32;|two}}
|align="right"|<code>&amp;#32;</code> is okay
|-
|{{Tlx|SISTER=W:|Tlx|x2|&amp;nbsp;|two}}
|{{Tlx|SISTER=W:|x2|&nbsp;|two}}
|align="right"|<code>&amp;nbsp;</code> is okay
|-
|{{Tlx|SISTER=W:|Tlx|x2| &amp;#124; two}}
|{{Tlx|SISTER=W:|x2| &#124; two}}
|align="right"|<code>&amp;#124;</code> is okay
|-
|| {{Tlx|SISTER=W:|Tlx|x2| {&#123;!&#125;} two}}
|| {{Tlx|SISTER=W:|x2| {{!}} two}}
|align="right"|{{Tlx|SISTER=W:|!}} is dubious
|-
|| {{Tlx|SISTER=W:|Tlx|x2|<nowiki>2=</nowiki>|<nowiki>3=two</nowiki>}}
|| {{Tlx|SISTER=W:|x2|2=|3=two}}
|empty really doesn't work
|-
|| {{Tlx|SISTER=W:|Tlx|x2|<nowiki>3=two</nowiki>|<nowiki>2=one</nowiki>}}
|| {{Tlx|SISTER=W:|x2|3=two|2=one}}
|align="right"|right to left okay
|}<includeonly>[[Category:Internal link templates|Tlx]]
----
<templatedata>
{ "description": "Template list expanded",
"params": {
"1": {
"label": "Template",
"description": "Linked template name",
"type": "string/wiki-page-name"
},
"2": {
"label": "Parameter",
"description": "Optional parameter",
"type": "string"
},
"3": {
"description": "For 2 parameters",
"type": "string"
},
"4": {
"description": "For 3 parameters",
"type": "string"
},
"5": {
"description": "For 4 parameters",
"type": "string"
},
"6": {
"description": "For 5 parameters",
"type": "string"
},
"7": {
"description": "For 6 parameters",
"type": "string"
},
"8": {
"description": "For 7 parameters",
"type": "string"
},
"9": {
"description": "For 8 parameters",
"type": "string"
},
"10": {
"description": "For 9 parameters",
"type": "string"
},
"11": {
"label": "Overflow",
"description": "Overflow shown as ...",
"type": "string"
},
"SISTER": {
"label": "Interwiki",
"description": "Optional InterWiki link prefix",
"type": "string"
} } }</templatedata></includeonly>


Here is how this template looks. Code to the left and actual rendering to the right:
==={{int:Seealso}}===
 
{{Template names}}
:{{tlc|tlx|name|parameters}} = {{tlx|name|parameters}}
 
Features of {{tl|tlx}}:
* It shows a template name with a link to that template.
* It shows up to eight parameters.
* It also shows empty parameters. (See examples below.)
* It prevents line wraps in its output.
 
This template belongs to a family of similar templates. For instance, when writing documentation you might want to avoid a lot of unnecessary links, since it decreases readability. Then on the first occurrence of a template name use {{tl|tl}}, or {{tlx|tlx}}, and then use {{tlf|tlf}}, {{tld|tld}} or {{tlc|tlc}}.
 
=== Examples ===
<table class="wikitable">
<tr><th>Code<th>Result<th>Comment
<tr><td>{{tlc|tlx}} <td>{{tlx}} <td>Shows its own syntax.
<tr><td>{{tlc|tlx|name}} <td>{{tlx|name}} <td>
<tr><td>{{tlc|tlx|name|one}} <td>{{tlx|name|one}} <td>
<tr><td>{{tlc|tlx|name|one|two}} <td>{{tlx|name|one|two}} <td>
<tr><td><code><nowiki>{{tlx|name|a|b|c|d|e|f|g|h|i|j}}</nowiki></code> <td>{{tlx|name|a|b|c|d|e|f|g|h|i}} <td>Shows up to eight parameters. The rest are dropped.
<tr><td>{{tlc|tlx|name|||three|four}} <td>{{tlx|name|||three|four}} <td>Also shows empty parameters.
<tr><td>{{tlc|tlx|name|||three||}} <td>{{tlx|name|||three||}} <td>Even shows empty parameters that come in the end.
<tr><td>{{tlc|tlx|name|3=one=a|4=two=b}} <td>{{tlx|name|one=a|two=b}} <td>Equal signs are a problem, but there is a fix.
<tr><td>{{tlc|tlx|name|3=2=one=a|4=3=two=b}} <td>{{tlx|name|2=one=a|3=two=b}} <td>Use numbered parameters to fix it. Remember to start from 2, since the "name" is number 1.
</table>
 
If you have equal signs in your template parameters then some find it simpler to code it using <code>&lt;nowiki></code> tags. Here's how to do that. Code to the left and actual rendering to the right:
 
:<code><nowiki>{{tlx|name|&lt;nowiki>one=a|two=b&lt;/nowiki>}}</nowiki></code> = {{tlx|name|<nowiki>one=a|two=b</nowiki>}}
 
<includeonly>
[[Category:Typing-aid templates|{{PAGENAME}}]]
[[Category:Internal link templates|{{PAGENAME}}]]
</includeonly>

Latest revision as of 20:32, 27 October 2022

This template creates example usage syntax for a template, and links the name to the template page. The name is derived from "Template list expanded".

Up to 7 pass parameters (numbered) for the specified template are displayed as 'placeholders', and more parameters are shown as "|...". An optional SISTER parameter can specify an interwiki prefix to link to another wiki. Examples:

Code Result Remark
{{Tlx|x0}} {{x0}}  
{{Tlx|x1|one}} {{x1|one}}  
{{Tlx|x2|one|two}} {{x2|one|two}}  
{{Tlx|x3|1|2|3}} {{x3|1|2|3}}  
{{Tlx|x4|1|2|3|4}} {{x4|1|2|3|4}} up to 7 parameters, then ...
{{Tlx|x4|1|2|3&#124;4}} {{x4|1|2|3|4}} &#124; for more
{{Tlx|x1|x=u}} {{x1}} = won't work
{{Tlx|x1|x&#61;u}} {{x1|x=u}} &#61; is okay
{{Tlx|x1|<nowiki>x=u</nowiki>}} {{x1|x=u}} sticky nowiki is okay
{{Tlx|x2| |two}} {{x2|two}} empty won't work
{{Tlx|x2|&#32;|two}} {{x2| |two}} &#32; is okay
{{Tlx|x2|&nbsp;|two}} {{x2| |two}} &nbsp; is okay
{{Tlx|x2| &#124; two}} {{x2| | two}} &#124; is okay
{{Tlx|x2| {{!}} two}} {{x2| | two}} {{!}} is dubious
{{Tlx|x2|2=|3=two}} {{x2|two}} empty really doesn't work
{{Tlx|x2|3=two|2=one}} {{x2|one|two}} right to left okay

See also

  • {{Tlc}}{{Example}} – Not linked, several parameters and text in <code></code> style.
  • {{Tld}}{{Example}} – Template link, several parameters and teletype text style[Please clarify – October 2024].
  • {{Tle}} – {{ TleExample }} – Linked or not, expanded parameter description
  • {{Tlf}}{{Example}} – Not linked, several parameters and normal text style.
  • {{Tl}}0{{Example}} – Linked, no parameters or simple ones[Please clarify – October 2024], and teletype text style[Please clarify – October 2024].
  • {{Tlx}} – {{Example}} – Template link, several parameters and normal text style.
  • {{Tlp}}{{Example}} – Template link, several non-blank parameters and normal text style.
  • {{Tlu}} – {{Example}} – Link to arbitrary other namespace.

with subst

For more see: Commons:Link templates

Contents
Cookies help us deliver our services. By using our services, you agree to our use of cookies.