Wikipedia:TemplateData/Tutorial: Difference between revisions

Content deleted Content added
Limitations and questions: give examples of special cases
Completing the TemplateData information: there is also a string/line type in the json documentation
Line 32:
 
For each parameter used by the template, complete the following <code>"params"</code> information:
:* Enter the parameter being used. For example, the [[Template:{{tl|Str left]]}} (<code><nowiki>{{Str left|<string>|<count>}}</nowiki>)</code>, has two positional parameters: string1 and count2.
:*Note: Both parameters in this template are only recognized by their position in the template, so they should be called "1" and "2" within the TemplateData information.
:* Enter the <code>"params"</code> value. In this example, the first parameter entered was <string> as parameter "1".
Line 38:
:** 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 "Alpha-numeric text".
:** 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, no decimal points), <code>"string/wiki-user-name"</code> or <code>"string/wiki-page-name"</code>., It<code>"string/line"</code> indicatesShort iftext it'sfield a- numberuse orfor anames, string.labels, and other short-form fields.
:** <code>"default"</code> contains the default value of this parameter (in quotes). The information can be skipped, if the parameter has no default value as in this example.
:** <code>"required"</code> controls whether filling out the parameter is mandatory for that template. Enter <code>true</code> if the value is required for the template and <code>false</code> if it is not required. In this case, both count and sub_string are required values.