Template:T/doc

From Pico Wiki
Jump to navigation Jump to search
Edit-copy green.svg
This is a page documentation subpage for Template:T.
It contains usage information, categories, interlanguage links and other content that is not part of the original Template page.

Description

This is a template link with a variable number of example parameters (0–30), which can be used to show example inputs.

Parameters

First parameter
The link to the template. Defaults to the page name (current page name: T/doc)
2nd to 31st parameter
The parameters of the demo template.
To add named parameters, example {{welcome|1st parameter|2nd parameter|text=3rd parameter}}, follow these steps:
  1. Write the parameter normally. Example: {{t|welcome|1st parameter|2nd parameter|text=3rd parameter}}.
  2. Then, count how many parameters you have added, so {{t|welcome|1st parameter|2nd parameter|text=3rd parameter}}.
    On this example, there are 4 parameters, so prefix 4= on the {{t}} template.
  3. So, the code is {{t|welcome|1st parameter|2nd parameter|4=text=3rd parameter}}, which results in {{welcome|1st parameter|2nd parameter|text=3rd parameter}}.
Note: Adding named parameters will force you to always prefix the unnamed parameter:
{{t|welcome|1st parameter|2nd parameter|4=3=3rd parameter|4th parameter}} will not work.
{{t|welcome|1st parameter|2nd parameter|4=3=3rd parameter|5=4th parameter}} will work.

The following will only work after all the parameters of the demo template is placed.
Wrong: {{t|welcome|style=code|<message>}}
Right: {{t|welcome|<message>|style=code}}

Style (style=)
The style of the {{t}} template. Has 3 styles:
  • (none) - encloses the {{t}} template with <code>
  • plain - encloses the {{t}} template with <span>
  • code - encloses the {{t}} template with <code> and adds styling to the code element.
  • pre - encloses the {{[[Template: |]]}} template with a HTML <pre> tag.
Prefix (prefix=)
The prefix for the template, useful when instructing the user to add subst, safesubst, or something similar.
Note: This does not add a prefix to the link itself. Use linkprefix instead as listed below.
Link Prefix (linkprefix=)
The prefix for the link itself, for linking to other languages/wikis. Also shows in the template link.
Note: This adds the prefix to the link itself. To add a prefix not included on the link, see above.
Block Mode (block=)
Makes the template styled as a block template, to aid in readablity. Combine with style=pre to get the best results.

Parameter limit

This template has a parameter limit of 30 items. If you exceed that limit, this will show up:

Template parameter limit reached! (help)

You can remove this warning and add more parameter checks to the template, however this might take some time depending on how many parameters you want.

If you want unlimited parameters alongside other features, please see w:c:dev:Global Lua Modules/T.

Examples

Basic

Syntax Output
{{t}} {{T/doc}} (uses the page name)
{{t|welcome}} {{welcome}}
{{t|welcome|Item1|Item2|Item3|Item4|Item5|...}} {{welcome|Item1|Item2|Item3|Item4|Item5|...}}
{{t|welcome|Item1|Item2|Item3|Item4|Item5|Item6|Item7|Item8|Item9|Item10|Item11|Item12|Item13|Item14|Item15|Item16|Item17|Item18|Item19|Item20|Item21|Item22|Item23|Item24|Item25|Item26|Item27|Item28|Item29|Item30}} {{welcome|Item1|Item2|Item3|Item4|Item5|Item6|Item7|Item8|Item9|Item10|Item11|Item12|Item13|Item14|Item15|Item16|Item17|Item18|Item19|Item20|Item21|Item22|Item23|Item24|Item25|Item26|Item27|Item28|Item29|Item30}}
{{t|welcome|Item1|Item2|Item3|Item4|Item5|Item6|Item7|Item8|Item9|Item10|Item11|Item12|Item13|Item14|Item15|Item16|Item17|Item18|Item19|Item20|Item21|Item22|Item23|Item24|Item25|Item26|Item27|Item28|Item29|Item30|Item31 (error}}} Template parameter limit reached! (help)

Named parameters

Syntax Output
{{t|welcome|2=param1=Item1}} {{welcome|param1=Item1}}
{{t|welcome|2=param1=Item1|3=param2=Item2}} {{welcome|param1=Item1|param2=Item2}}
{{t|welcome|example|3=param1=Item1|4=param2=Item2}} {{welcome|example|param1=Item1|param2=Item2}}

Prefixes

Syntax Output
{{t|welcome|prefix=subst}} {{subst:welcome}}
{{t|welcome|linkprefix=w}} {{w:welcome}}
{{t|welcome|linkprefix=w|prefix=subst}} {{subst:w:welcome}}

Styling

Syntax Output
Normal
{{t|welcome|style=code}} {{welcome}}
{{t|welcome|style=plain}} {{welcome}}
{{t|welcome|2=Item1|3=Item2|4=Item3|style=pre}}
{{welcome|Item1|Item2|Item3}}
With block=
{{t|welcome|style=code|block=yes}} {{welcome
}}
{{t|welcome|style=plain|block=yes}} {{welcome
}}
{{t|welcome|2=Item1|3=Item2|4=Item3|style=pre|block=yes}}
{{welcome
|Item1
|Item2
|Item3
}}

Full usage

{{t|welcome|2=param1=Item1|3=param2=Item2|4=param3=Item3<br/>...|5=param10=Item10|block=true|style=pre|prefix=subst}}

{{subst:welcome
|param1=Item1
|param2=Item2
|param3=Item3
...
|param10=Item10
}}

See also