Jump to content

Template:Template data/doc

From Wikipedia, the free encyclopedia

The {{Template data}} template inserts template data into a documentation page using parameters as input.

In order to ensure compatibility with the template data editor, it is suggested (although it is not required) that this template be substituted ({{subst:Template data|...}}) as soon as the documented template enters a stable phase.

Usage

[edit]

The following wikitext

{{Template data

	| description = Use this template to indicate that an article is in need of cleanup.
	| format = inline

	| label 1 = Example parameter 1
	| description 1 = Example parameter description 1
	| type 1 = string

	| label 2 = Example parameter 2
	| description 2 = Example parameter description 2
	| type 2 = string
	| example 2 = Hello world

	| name 3 = date
	| label 3 = Month and year
	| description 3 = The month and year that the template was added
	| type 3 = string
	| auto value 3 = <nowiki>{{SUBST:CURRENTMONTHNAME}} {{SUBST:CURRENTYEAR}}</nowiki>
	| example 3 = January 2013
	| suggested 3 = true

	| name 4 = reason
	| aliases 4 = 3
	| label 4 = Reason
	| description 4 = The reason the article is in need of cleanup
	| type 4 = string

	| name 5 = talk
	| aliases 5 = talksection, talkpart
	| label 5 = Talk page section
	| description 5 = The section of the talk page containing relevant discussion
	| type 5 = string

	| param order = 1, 2, date, reason, talk

}}

will expand into the following wikitext:

<templatedata>{
	"description": "Use this template to indicate that an article is in need of cleanup.",
	"format": "inline",
	"params": {
		"1": {
			"type": "string",
			"description": "Example parameter description 1",
			"label": "Example parameter 1"
		},
		"2": {
			"example": "Hello world",
			"type": "string",
			"description": "Example parameter description 2",
			"label": "Example parameter 2"
		},
		"date": {
			"suggested": true,
			"type": "string",
			"description": "The month and year that the template was added",
			"label": "Month and year",
			"example": "January 2013",
			"autovalue": "{{SUBST:CURRENTMONTHNAME}} {{SUBST:CURRENTYEAR}}"
		},
		"reason": {
			"aliases": [
				"3"
			],
			"type": "string",
			"description": "The reason the article is in need of cleanup",
			"label": "Reason"
		},
		"talk": {
			"aliases": [
				"talksection",
				"talkpart"
			],
			"type": "string",
			"description": "The section of the talk page containing relevant discussion",
			"label": "Talk page section"
		}
	},
	"paramOrder": [
		"1",
		"2",
		"date",
		"reason",
		"talk"
	]
}</templatedata>

All parameters maintain the same name as the corresponding field in the JSON object, in which ordinarily spaced lower-case names are converted to either camel case (e.g. "param order" → "paramOrder") or flatcase (e.g. "suggested values" → "suggestedvalues") without the number suffix, when present. The array-containing parameters |param order=, |suggested values N=, and |aliases N= by default use the comma as separator; you can specify a different separator via the special parameters |param order separator=, |suggested value separator N=, and |alias separator N= (e.g.: |suggested value separator 2=///).

Parameter documentation

[edit]

The following documentation has been written using this very template.

Use this template to insert template data into a documentation page using parameters as input.

Template parameters

This template prefers block formatting of parameters.

ParameterDescriptionTypeStatus
Template descriptiondescription

The 'description' parameter describes what the template does. It is optional but highly recommended.

Stringsuggested
Template formatformat

The 'format' parameter describes how the template's wikitext should be laid out. This can be set to the standard formats of 'inline' and 'block', or the user can input a set of wikitext symbols to create a custom format.

Example
block
Stringoptional
Parameter orderparam order

The 'param order' parameter is an optional list that causes the parameters of a template to be displayed in a specific order when added in the template editor. By default it expects a comma as separator; you can specify a different separator via the special parameter 'param order separator'.

Example
1, 2, date, reason, talk
Stringoptional
Parameter order separatorparam order separator

By default the 'param order' parameter expects a comma as separator; using this parameter you can specify a different separator.

Example
///
Stringoptional
First parameter's namename 1

Name of the first parameter. When omitted it defaults to the numeric suffix of this parameter name ('1').

Default
1
Stringoptional
First parameter's labellabel 1

Label of the first parameter.

Stringsuggested
First parameter's descriptiondescription 1

Description of the first parameter.

Stringsuggested
First parameter's aliasesaliases 1

Aliases of the first parameter. By default this parameter expects a comma as separator; you can specify a different separator via the special parameter 'alias separator 1'.

Stringoptional
Alias separatoralias separator 1

By default the 'aliases 1' parameter expects a comma as separator; using this parameter you can specify a different separator.

Example
///
Stringoptional
First parameter's aliasesinherits 1

This is an optional parameter for when the first parameter should inherit all of the template data of another parameter. These can then be overridden by any parameters specified for the inheriting parameter.

Stringoptional
First parameter's typetype 1

Currently the supported types are: 'unknown', 'string', 'line', 'content', 'unbalanced-wikitext', 'wiki-page-name', 'wiki-file-name', 'wiki-template-name', 'wiki-user-name', 'number', 'boolean', 'date', 'url'

Stringsuggested
First parameter's default valuedefault 1

Some template parameters have a default value; the value is used unless overridden by the user. The 'default 1' item is an optional item, documentary only, that is intended to communicate this default value of the first parameter to the user. The value need not match the actual default (if there is one) and has no functional effect. (Not to be confused with "auto value 1", which is a functional parameter that fills in a field for the user.)

Stringoptional
First parameter's auto valueauto value 1

The first parameter can be assigned an 'auto value 1'. When a user adds the template to a page, this value will automatically appear in the input box. For example, many cleanup templates need the date added; setting the 'auto value 1' for the template's first parameter to be {{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}, the month and year that the template was added will be filled in automatically.

Example
<nowiki>{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}</nowiki>
Stringoptional
First parameter's example valueexample 1

The 'example 1' parameter is optional and documentary only; its value contains an example that helps the template's user understand the correct way to fill in the first parameter (not to be confused with 'suggested 1'; see that entry for more information).

Stringoptional
First parameter's suggested valuessuggested values 1

The parameter property 'suggested values 1' lets you define a list of values for the first parameter to be shown to visual editor users in a dropdown for easy selection. You can add suggested values to be displayed in the visual editor for parameters which have their type set to one of the following options: 'Content', 'Line', 'String', 'Number', 'Unknown', 'Unbalanced wikitext'. Other types ('file', 'page', 'template', 'user', 'date', 'boolean', 'URL') are not currently supported because they have special functionalities in the visual editor already, such as autocomplete, which would interfere with the drop-down menu for suggested values in the visual editor. By default this parameter expects a comma as separator; you can specify a different separator via the special parameter 'suggested value separator 1'.

Stringoptional
First parameter's suggested value separatorsuggested value separator 1

By default the 'suggested values 1' parameter expects a comma as separator; using this parameter you can specify a different separator.

Example
///
Stringoptional
First parameter's required statusrequired 1

The 'required 1' parameter can be set to either 'true' or 'false'. When unspecified the value defaults to 'false'. It determines whether filling in the first parameter is mandatory for the template.

Booleanoptional
First parameter's suggested statussuggested 1

The 'suggested 1' parameter can be set to either 'true' or 'false'. When unspecified the value defaults to 'false'. Use 'suggested 1' when the first parameter is not mandatory but strongly recommended for template users to provide. When filling in this parameter, the user will see this suggestion.

Booleanoptional
First parameter's deprecated statusdeprecated 1

The 'deprecated 1' parameter can be set to 'true', 'false', or a string describing what users should instead do. When unspecified the value defaults to 'false'. This is a status for when the first parameter should not be used any more but still exist for the time being. This could be because uses of the template are being moved from one set of parameters to another.

Stringoptional

Helper subtemplates

[edit]

See also

[edit]