Wikipedia:TemplateData/Tutorial: Difference between revisions
Content deleted Content added
Okeyes (WMF) (talk | contribs) →Save: tweak |
m →Completing the TemplateData information: some <code>s |
||
Line 25:
===Completing the TemplateData information===
The first tag is a <code>"description"</code>, which is fairly self-explanatory; it describes what the template does. You may use information that you glean from the top of the main or subpage of the template, which is then put in quotes {" "}.
For each parameter used by the template, complete the following <code>"params"</code> information:
:* Enter the parameter being used. For example, the [[Template:Str left]] (<nowiki>{{Str left|<string>|<count>}}</nowiki>), has two parameters: string and count.
:* Enter the <code>"params"</code> value. In this example, the first parameter entered was "count"
:* Then add the information about each parameter.
:** The <code>"label"</code> is a human-readable title for the parameter that will be displayed within the template editor. Capitalize the first character of the label (since it will be the leftmost value in the resulting table), and put it in quotes. In this case, it is "Quantity".
:** Enter the <code>"description"</code>, this time a description of the parameter, not of the template as a whole. This is also likely on the main or subpage. Put the information in quotes.
:** The <code>"type"</code>, which controls how the template editor will interpret that parameter. This can be <code>"string"</code> (a set of characters, like this sentence!), <code>"number"</code> (a set of digits), <code>"string/wiki-user-name"</code> or <code>"string/wiki-page-name"</code>. It indicates if it's a number or a string.
:** <code>"Required"</code> controls whether filling out the parameter is mandatory for that template. Enter
:* Where there are more than one parameter passed to the template, add a comma after the close bracket,
<!--"default" is missing-->
<source lang="javascript">
<templatedata>{
"params": {
▲ "description": "A template to give the <count> substring of characters from the start of the trimmed string ",
▲ "description": "Gives the <count> substring of characters from the start of the trimmed string",
▲ "type": "number",
},
▲ "required": true
▲ "string": {
"description": "The string to be trimmed and counted",
▲ "label": "Alpha-numeric text",
}
▲ "required": true
}}</templatedata>▼
▲</templatedata>
</source>
|