Template:Template link general/doc: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content deleted Content added
update /doc to make it more of a centralized container
Line 3:
{{lua|Module:Tlg}}
 
This template, often abbreviated as {{tlf|{{#switch:{{lc:{{ROOTPAGENAME}}}}
{{tl|tlg}} (abbreviating "[t]emplate [l]ink {{small|(with)}} [g]eneral {{small|(options)}}") is a generalised version of the {{tl|tl}} ("template link") template. It can be used to replace or implement {{tlf|tl}} and related templates such as {{tl|tlb}}, {{tl|tlx}}, etc.
| tlg | template link general = tlg
| tlb | template link with bold = tlb
| tlc | template link code = tlc}}
}}, is used to provide stylized links to templates without expanding the template itself.
 
===Parameters===
With the exception of {{mono|alttext}}, {{tlf|tlg}}'sthe named parameters are toggles that are either omitted (default in most cases) or activated (by being assigned a value such as "on", "yes", "true", "include", etc.). They may be included in any order ([[Template:Tlg#Examples|see Examples below]]):. Certain templates have the parameter "on" by default; see [[#General-purpose formatting|the main table]] for all alternate options.
====Named====
 
With the exception of {{mono|alttext}}, {{tlf|tlg}}'s named parameters are toggles that are either omitted (default) or activated (by being assigned a value such as "on", "yes", "true", "include", etc.). They may be included in any order ([[Template:Tlg#Examples|see Examples below]]):
{| class="wikitable"
! Parameter || Action || AsDefault inactive
|-
| brace || Include braces as part of the template link || {{tl|tlw}}/{{tl|tn}}
|-
| braceinside || Include innermost braces as part of the template link || {{tl|tlw}}
|-
| bold<br/>boldlink<br/>boldname || Renders the template link/name in '''bold''' || {{tl|tlb}}, {{tl|tlxtlxb}}, etc.
|-
| code || Display output using HTML [[HTML element#code|{{tag|code}}]] tags ([[monospaced font]]) || {{tl|tlc}}, {{tl|tlx}}, etc.
|-
| italic || Display any parameters accompanying the template link/name in ''italics'' || {{tl|tlxi}}
| plaincode || Uses {{tag|code|params=style="border:none; background:transparent;"}} ||
|-
| kbd || Display output using HTML [[HTML element#kbd|{{tag|kbd}}]] tags (monospaced font) || {{tl|tltt}}, {{tl|tltt2}}, etc.
|-
| italic<br/>italicsnolink || Display anyDon't parameters accompanyingrender the template link/name inas ''italic/s''a link || {{tl|tlxitlf}}, {{t|tlc}}, {{t|tnull}}
|-
| nowrap || Prevent the insertion of line breaks ([[word wrap]]) in the output || {{tl|tlp}}, {{tl|tlf}}, etc.
| nolink || Don't render the template name as a link || {{tl|tlf}}
|-
| nowrap || Prevent the insertion of line breaks ([[word wrap]]) in the output || {{tl|tlp}}, {{tl|tlf}}, etc.
|-
| nowrapname || Prevent word wrapping in the output of template name/link (parameters will wrap if needed) ||
|-
| plaincode || Uses {{tag|code|params=style="border:none; background:transparent;"}} || {{tl|tltss}}
| subst || Include a [[Help:Substitution|subst:]] prefix before the template link/name || {{tl|tls}}
|-
| subst || Include a [[Help:Substitution|subst:]] prefix before the template link/name || {{tl|tls}}, {{tl|tlxs}}, etc
|-
| <nowiki>{{para|alttext=|[text]</nowiki>}} || Use [text] as the label for the template link || {{tl|tla}}
|}
 
====Unnamed (Positional)====
{{tlf|tlg}}This maytemplate taketakes up to ten [[unnamed parameter]]s as parameters accompanying the template link (or name); see Examples below.
 
===Examples===
Line 48 ⟶ 52:
|style=background-color:transparent;<!-- to see background of <code>...</code> -->
| '''Code''' | '''Output''' | '''Remarks'''
| {{tlx|tlg{{ROOTPAGENAME}}|Termometro}} | {{tlg{{ROOTPAGENAME}}|Termometro}} | {{error|Termometro}} template does not exist. Be aware with linking to non-existing templates, although desired.
| {{tlx|tlg{{ROOTPAGENAME}}|ok}} | {{tlg{{ROOTPAGENAME}}|ok}} | ok template does exist
| {{tlx|tlg{{ROOTPAGENAME}}|convert|<nowiki>&lt;nowiki>14|m|ftin|abbr=out|sp=us&lt;/nowiki></nowiki>}} | {{tlg{{ROOTPAGENAME}}|convert|<nowiki>14|m|ftin|abbr=out|sp=us</nowiki>}} | Unlimited parameters as one {{tag|nowiki|link=yes}} [[Help:Wikitext#Nowiki|string]]
| {{tlx|tlg{{ROOTPAGENAME}}|Abc}} | {{tlg{{ROOTPAGENAME}}|Abc}} |
| {{tlx|tlg{{ROOTPAGENAME}}|abC}} | {{tlg{{ROOTPAGENAME}}|abC}} | template names are case-sensitive
| {{tlx|tlg{{ROOTPAGENAME}}|abc}} | {{tlg{{ROOTPAGENAME}}|abc}} | first letter is case-insensitive though
| {{tlx|tlg{{ROOTPAGENAME}}|abc|'''<nowiki>{{spaces}}</nowiki>'''{{{1}}}'''<nowiki>{{spaces}}</nowiki>'''}} | {{tlg{{ROOTPAGENAME}}|abc|{{spaces}}{{{1}}}{{spaces}}}}| Using {{tl|spaces}} before and after <nowiki>{{{1}}}</nowiki> parameter.
| {{tlx|tlg{{ROOTPAGENAME}}|x0}} | {{tlg{{ROOTPAGENAME}}|x0}} |
| {{tlx|tlg{{ROOTPAGENAME}}|x0|code{{=}}on}} | {{tlg{{ROOTPAGENAME}}|x0|code=on}} | &lt;code&gt; style
| {{tlx|tlg{{ROOTPAGENAME}}|x0|plaincode{{=}}on}} | {{tlg{{ROOTPAGENAME}}|x0|plaincode=on}} | plaincode style
| {{tlx|tlg{{ROOTPAGENAME}}|x0|kbd{{=}}on}} | {{tlg{{ROOTPAGENAME}}|x0|kbd=on}} | &lt;kbd&gt; style
| {{tlx|tlg{{ROOTPAGENAME}}|x0|bold{{=}}on}} | {{tlg{{ROOTPAGENAME}}|x0|bold=on}} | bold link/name
| {{tlx|tlg{{ROOTPAGENAME}}|x1|one|italic{{=}}on}} | {{tlg{{ROOTPAGENAME}}|x1|one|italic=on}} | parameter/s in italics
| {{tlx|tlg{{ROOTPAGENAME}}|x0|nolink{{=}}on}} | {{tlg{{ROOTPAGENAME}}|x0|nolink=on}} |
| {{tlx|tlg{{ROOTPAGENAME}}|x0|subst{{=}}on}} | {{tlg{{ROOTPAGENAME}}|x0|subst=on}} |
| {{tlx|tlg{{ROOTPAGENAME}}|x0|brace{{=}}on}} | {{tlg{{ROOTPAGENAME}}|x0|brace=on}} | all braces in link
| {{tlx|tlg{{ROOTPAGENAME}}|x0|braceinside{{=}}on}} | {{tlg{{ROOTPAGENAME}}|x0|braceinside=on}} | inside braces in link
| {{tlx|tlg{{ROOTPAGENAME}}|x0|alttext{{=}}x0 link}} | {{tlg{{ROOTPAGENAME}}|x0|alttext=x0 link}} |
| {{tlx|tlg{{ROOTPAGENAME}}|x0|bold{{=}}on|code{{=}}on|brace{{=}}on}} | {{tlg{{ROOTPAGENAME}}|x0|bold=on|code=on|brace=on}} | No reason you can't combine multiple parameter settings
| {{tlx|tlg{{ROOTPAGENAME}}|x1|one}} | {{tlg{{ROOTPAGENAME}}|x1|one}} |
| {{tlx|tlg{{ROOTPAGENAME}}|x2|one|two}} | {{tlg{{ROOTPAGENAME}}|x2|one|two}} |
| {{tlx|tlg{{ROOTPAGENAME}}|x2|bold{{=}}on|code{{=}}on|one|two}} | {{tlg{{ROOTPAGENAME}}|x2|bold=on|code=on|one|two}} | Can combine named and anonymous parameters …
| {{tlx|tlg{{ROOTPAGENAME}}|x2|one|two|bold{{=}}on|code{{=}}on}} | {{tlg{{ROOTPAGENAME}}|x2|one|two|bold=on|code=on}} | … in any order …
| {{tlx|tlg{{ROOTPAGENAME}}|x2|one|code{{=}}on|two|bold{{=}}on|three}} | {{tlg{{ROOTPAGENAME}}|x2|one|code=on|two|bold=on|three}} | … even intermixed …
| {{tlx|tlg{{ROOTPAGENAME}}|x2|one|code{{=}}on|two|bold{{=}}on|three|italic{{=}}on}} | {{tlg{{ROOTPAGENAME}}|x2|one|code=on|two|bold=on|three|italic=on}} | … with many different configurations.
| {{tlx|tlg{{ROOTPAGENAME}}|x3|1|2|3|4|5|6|7|8|9&#124;|10}} | {{tlg{{ROOTPAGENAME}}|x3|1|2|3|4|5|6|7|8|9|10}} |
| {{tlx|tlg{{ROOTPAGENAME}}|x4|1|2|3|4|5|6|7|8|9&#124;|10&#124;|11}} | {{tlg{{ROOTPAGENAME}}|x4|1|2|3|4|5|6|7|8|9|10|11}} | up to 10 parameters, then …
| {{tlx|tlg{{ROOTPAGENAME}}|x5|1|2|3|4|5|6|7|8|9&#124;|10&amp;#124;11}} | {{tlg{{ROOTPAGENAME}}|x5|1|2|3|4|5|6|7|8|9|10&#124;11}} | {{align|right|<code>&amp;#124;</code> for more}}
| {{tlx|tlg{{ROOTPAGENAME}}}} | {{tlgROOTPAGENAME}} | with no arguments, the current page name is substituted
| {{tlx|tlg{{ROOTPAGENAME}}|x1|x&#61;u}} | {{tlg{{ROOTPAGENAME}}|x1|x=u}} | '''{{=}}''' won't work
| {{tlx|tlg{{ROOTPAGENAME}}|x1|x&amp;#61;u}} | {{tlg{{ROOTPAGENAME}}|x1|x&#61;u}} | {{align|right|<code>&amp;#61;</code> is okay}}
| {{tlx|tlg{{ROOTPAGENAME}}|x1|x<nowiki>{{=}}</nowiki>u}} | {{tlg{{ROOTPAGENAME}}|x1|x{{=}}u}} | {{align|right|<code><nowiki>{{=}}</nowiki></code> is okay (see [[:template:=|template equal sign]])}}
| {{tlx|tlg{{ROOTPAGENAME}}|x1|x&lt;nowiki&gt;&#61;&lt;/nowiki&gt;u}} | {{tlg{{ROOTPAGENAME}}|x1|x<nowiki>=</nowiki>u}} | {{align|right|sticky nowiki is okay}}
| {{tlx|tlg{{ROOTPAGENAME}}|x2|<nowiki />|two|<nowiki />|<nowiki />}} | {{tlg{{ROOTPAGENAME}}|x2||two||}} | empty parameters work too, even at the end
| {{tlx|tlg{{ROOTPAGENAME}}|x2|<nowiki>3=two</nowiki>|<nowiki>2=one</nowiki>}} | {{tlg{{ROOTPAGENAME}}|x2|3=two|2=one}} | {{align|right|right to left okay}}
}}
 
Line 91 ⟶ 95:
! style="width:15em;" | Output
|-
| {{tlx|tlg{{ROOTPAGENAME}}|long template name that would wrap to new line|this is a long value for the 1st parameter that would wrap}}
| {{tlg{{ROOTPAGENAME}}|long template name that would wrap to new line|this is a long value for the 1st parameter that would wrap}}
|}
 
Line 101 ⟶ 105:
! style="width:15em;" | Output
|-
| {{tlx|tlg{{ROOTPAGENAME}}|nowrap{{=}}on|long template name that would wrap to new line|long value for the 1st parameter that would wrap}}
| {{tlg{{ROOTPAGENAME}}|nowrap=on|long template name that would wrap to new line|long value for the 1st parameter that would wrap}}
|}
 
Line 111 ⟶ 115:
! style="width:15em;" | Output
|-
| {{tlx|tlg{{ROOTPAGENAME}}|nowrapname{{=}}on|long template name that would wrap to new line|long value for the 1st parameter that would wrap}}
| {{tlg{{ROOTPAGENAME}}|nowrapname=on|long template name that would wrap to new line|long value for the 1st parameter that would wrap}}
|}
 

Revision as of 17:13, November 20, 2020

This template, often abbreviated as {{tlg}}, is used to provide stylized links to templates without expanding the template itself.

Parameters

With the exception of Template:Mono, the named parameters are toggles that are either omitted (default in most cases) or activated (by being assigned a value such as "on", "yes", "true", "include", etc.). They may be included in any order (see Examples below). Certain templates have the parameter "on" by default; see the main table for all alternate options.

Parameter Action Default active
brace Include braces as part of the template link {{tlw}}/{{tn}}
braceinside Include innermost braces as part of the template link
bold Renders the template link/name in bold {{tlb}}, {{tlxb}}
code Display output using HTML <code>...</code> tags (monospaced font) {{tlc}}, {{tlx}}, etc.
italic Display any parameters accompanying the template link/name in italics {{tlxi}}
kbd Display output using HTML <kbd>...</kbd> tags (monospaced font)
nolink Don't render the template name as a link {{tlf}}, {{tlc}}, {{tnull}}
nowrap Prevent the insertion of line breaks (word wrap) in the output
nowrapname Prevent word wrapping in the output of template name/link (parameters will wrap if needed)
plaincode Uses <code style="border:none; background:transparent;">...</code> {{tltss}}
subst Include a subst: prefix before the template link/name {{tls}}, {{tlxs}}, etc
|alttext=[text] Use [text] as the label for the template link {{tla}}

Unnamed (Positional)

This template takes up to ten unnamed parameters as parameters accompanying the template link (or name); see Examples below.

Examples

Note
On the source sister projects, en.wikipedia and Meta, X0, X1, X2, …, X9 are sandbox templates for experimentation on involved templates that need be in template space. An auto-cleansing software facility exists that might be used to duplicate the facility on other Sister projects.

Script error: No such module "aligned table".

Wrapping of long names (default)
Code Output
{{Template link general|long template name that would wrap to new line|this is a long value for the 1st parameter that would wrap}} {{Template:!((:Template:Long template name that would wrap to new line|long template name that would wrap to new line]]|this is a long value for the 1st parameter that would wrap}}
Wrapping of long names (nowrap=on)
Code Output
{{Template link general|nowrap=on|long template name that would wrap to new line|long value for the 1st parameter that would wrap}} {{Template:!((:Template:Long template name that would wrap to new line|long template name that would wrap to new line]]|long value for the 1st parameter that would wrap}}
Wrapping of long names (nowrapname=on)
Code Output
{{Template link general|nowrapname=on|long template name that would wrap to new line|long value for the 1st parameter that would wrap}} {{Template:!((:Template:Long template name that would wrap to new line|long template name that would wrap to new line]]|long value for the 1st parameter that would wrap}}

See also

Template:Template-linking templates