Wikipedia:TemplateData/Tutorial: Difference between revisions

Content deleted Content added
removed in use tag
consolidate info from 2 areas
Line 25:
 
===Completing the templatedata information===
The first value in the templatedata section is the description. The first tag is a "description", which is fairly self-explanatory; it describes what the template does. Use information that you glean from the top of the main or subpage for the template to describe how the template is used and put that information in quotes {" "}.
 
Then, for each parameter used by the template, complete the following "params" information:
:* Enter the parameter being used. For example, per the [[Template:Str left]] information, <nowiki>{{Str left|<string>|<count>}}</nowiki>, the template has two parameters: string and count.
:* Enter the "params" value. In this example, the first parameter entered was "count"
:* Then add the information about each parameter.
:* Then add the information about each parameter. The label is the descriptive information for the value that should be entered for the value, capitalizing the first character of the label (since it will be the leftmost value in the resulting table). In this case, it is Quantity. Next, enter the description, which is also likely on the main or subpage. The type indicates if it's a number or a string. For required, enter "true" if the value is required for the template and "false" if it is not required. In this case, both count and sub_string are required values.
:** The "label" 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. In this case, it is Quantity.
:** Enter the "description", this time a description of the parameter, not of the template as a whole. This is also likely on the main or subpage.
:** The "type", which controls how the template editor will interpret that parameter. This can be "string" (a set of characters, like this sentence!), "number" (a set of digits), "string/wiki-user-name" or "string/wiki-page-name".indicates if it's a number or a string.
:** "Required" controls whether filling out the parameter is mandatory for that template. Enter "true" if the value is required for the template and "false" if it is not required. In this case, both count and sub_string are required values.
:* Where there are more than one parameter passed to the template, add a comma after the close bracket, "}," between the parms values.
 
Line 54 ⟶ 58:
</templatedata>
</pre>
 
===Save===
Once you're done, hit "save". If you've made errors, it will not let you save - which we appreciate is disruptive, but means you can't break anything. Some commons things to look for are matched sets of quotes {""}, matched brackets ({}), and comma between multiple params sections.
 
Should you run into errors, explain on the feedback page what you were trying to do, and we'll be happy to help.
 
This would display in the template like so:
 
Line 109 ⟶ 119:
------>
 
=== What it all means Help===
Should you run into errors, explain on the [[Wikipedia:VisualEditor/Feedback|feedback page]] what you were trying to do, and we'll be happy to help.
So let's break that down. The first tag is a "description", which is fairly self-explanatory; it describes what the template does. There is then a "params" tag, which indicates that subsequent sections cover each parameter in the template.
 
Within each subsection, the first tag is the name of the template parameter ''within the template'' - if the parameter is simply called "1", this tag would be "1". Next we have "label", in which you put a human-readable title for the parameter that will be displayed within the template editor. We then have "description" - this time a description of the parameter, not of the template as a whole. After that we have "type", which controls how the template editor will interpret that parameter. This can be "string" (a set of characters, like this sentence!), "number" (a set of digits), "string/wiki-user-name" or "string/wiki-page-name". We then have "required", which can be set to either true or false; this simply controls whether filling out the parameter is mandatory for that template.
 
If you have multiple parameters, just repeat each params section and fill it out as you see fit. Add a comma after the close bracket, "}," between the parms values. Once you're done, hit "save". If you've made errors, it will not let you save - which we appreciate is disruptive, but means you can't break anything. Should you run into errors, explain on the [[Wikipedia:VisualEditor/Feedback|feedback page]] what you were trying to do, and we'll be happy to help.
 
== Limitations and questions ==