Template:Tlc: Difference between revisions
More actions
Creating this "tl code" template similar to {{tlx}} but without the link. |
m Protected "Template:Tlc": Widely used template ([Edit=Allow only template editors and administrators] (indefinite) [Move=Allow only template editors and administrators] (indefinite)) |
||
| (5 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
< | <onlyinclude><!-- | ||
-->{{#ifeq:{{{2|x}}}|{{{2|}}}| |{{{2}}} | --><templatestyles src="Template:Nowrap/styles.css"/><!-- | ||
-->{{#ifeq:{{{3|x}}}|{{{3|}}}| |{{{3}}} | --><code class="nowrap"><!-- | ||
-->{{#ifeq:{{{4|x}}}|{{{4|}}}| |{{{4}}} | -->{{<!-- | ||
-->{{#ifeq:{{{5|x}}}|{{{5|}}}| |{{{5}}} | --><includeonly>{{{1}}}</includeonly><!-- | ||
-->{{#ifeq:{{{6|x}}}|{{{6|}}}| |{{{6}}} | --><noinclude>tlc|...</noinclude><!-- | ||
-->{{#ifeq:{{{7|x}}}|{{{7|}}}| |{{{7}}} | -->{{#ifeq:{{{2|x}}}|{{{2|}}}| |{{{2}}} }}<!-- | ||
-->{{#ifeq:{{{8|x}}}|{{{8|}}}| |{{{8}}} | -->{{#ifeq:{{{3|x}}}|{{{3|}}}| |{{{3}}} }}<!-- | ||
-->{{#ifeq:{{{9|x}}}|{{{9|}}}| |{{{9}}} | -->{{#ifeq:{{{4|x}}}|{{{4|}}}| |{{{4}}} }}<!-- | ||
-->}}</code>< | -->{{#ifeq:{{{5|x}}}|{{{5|}}}| |{{{5}}} }}<!-- | ||
-->{{#ifeq:{{{6|x}}}|{{{6|}}}| |{{{6}}} }}<!-- | |||
-->{{#ifeq:{{{7|x}}}|{{{7|}}}| |{{{7}}} }}<!-- | |||
-->{{#ifeq:{{{8|x}}}|{{{8|}}}| |{{{8}}} }}<!-- | |||
-->{{#ifeq:{{{9|x}}}|{{{9|}}}| |{{{9}}} }}<!-- | |||
-->}}<!-- | |||
--></code><!-- | |||
--></onlyinclude> | |||
{{ | {{Documentation}} | ||
<!-- Add categories and interwikis to the /doc subpage, not here! --> | <!-- Add categories and interwikis to the /doc subpage, not here! --> | ||
Latest revision as of 08:25, 28 August 2024
{{tlc|...}}
This is the {{tlc}} template.
This page also serves as the full documentation for {{Tlf}} (doc page), that works almost exactly the same.
When showing a template name with brackets in documentation you have to escape the brackets in some way so it doesn't become a call to the template. Instead of using <nowiki></nowiki> tags you can write it simpler and shorter by using these templates.
Here is how these templates look. Code to the left and actual rendering to the right:
{{tlc|name|parameters}}={{name|parameters}}{{tlf|name|parameters}}= {{name|parameters}}
These templates work similarly to {{Tl}} and {{tlx}}, but they don't make the template name into a link. When writing documentation you might want to avoid a lot of unnecessary links, since it decreases readability. So on the first occurrence of a template name use {{Tl}}, {{tld}} or {{tlx}}, and then use {{tlc}} or {{tlf}}.
Features of {{tlc}}, {{tld}}, {{tlf}} and {{tlp}}:
- They show a template name and up to eight parameters.
- They also show empty parameters. (See examples below.)
- They prevent line wraps in their output.
Examples
Wikitables make the <code></code> tags transparent, that's why the "code colouring" is missing in these examples.
| Code | Result | Comment |
|---|---|---|
{{tlc}} | {{{{{1}}}}} | Shows its own syntax. |
{{tlc|name}} | {{name}} | |
{{tlc|name|one}} | {{name|one}} | |
{{tlc|name|one|two}} | {{name|one|two}} | |
{{tlc|name|a|b|c|d|e|f|g|h|i|j}} | {{name|a|b|c|d|e|f|g|h}} | Shows up to eight parameters. The rest are dropped. |
{{tlc|name|||three|four}} | {{name|||three|four}} | Also shows empty parameters. |
{{tlc|name|||three||}} | {{name|||three||}} | Even shows empty parameters that come in the end. |
{{tlc|name|one=a|two=b}} | {{name}} | Equal signs is a problem, but there is a fix. |
{{tlc|name|2=one=a|3=two=b}} | {{name|one=a|two=b}} | Use numbered parameters to fix it. Remember to start from 2, since the "name" is number 1. |
If you have equal signs in your template parameters, you should replace them with {{=}}, but it probably is simpler and clearer to code it using <nowiki> tags etc. Here are the codes to emulate {{tlf}} and {{tlc}} respectively. Code to the left and actual rendering to the right:
<span class="nowrap"><nowiki>{{name|one=a|two=b}}</nowiki></span>→ {{name|one=a|two=b}}<code class="nowrap"><nowiki>{{name|one=a|two=b}}</nowiki></code>→{{name|one=a|two=b}}
TemplateData
- TemplateData
TemplateData is a way to store information about template parameters (the description of those and of the whole template) for both humans and machines. It is used by VisualEditor and possibly other tools like Upload Wizard.
Existing template documentation
At Wikimedia Commons, it is recommended to use {{TemplateBox}} with either useTemplateData=1 or useTemplateData=only on the /doc subpage and transcluding it with {{Documentation}} into the template. <nowiki>-tags can be wrapped around the arguments, if required, to avoid templates being expanded.
Newly created template documentation and imports
Another option, especially for imported templates, or for users with JSON experience, is placing raw <templatedata>-tags into the Wikitext of the template, as described in various Wikipediae.
Wikipedia's help about TemplateData • Commons-specific information
Template link code
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Template | 1 | Linked template name | Template | required |
| Parameter 1 | 2 | First parameter value | String | optional |
| Parameter 2 | 3 | Second parameter value | String | optional |
| Parameter 3 | 4 | Third parameter value | String | optional |
| Parameter 4 | 5 | Fourth parameter value | String | optional |
| Parameter 5 | 6 | Fifth parameter value | String | optional |
| Parameter 6 | 7 | Sixth parameter value | String | optional |
| Parameter 7 | 8 | Seventh parameter value | String | optional |
| Parameter 8 | 9 | Eight parameter value | String | optional |