Template:Templatedata

From Terraria Wiki
Jump to navigation Jump to search
This template uses Lua.
This template uses Module:Format TemplateData, a script written in the Lua programming language. To learn more about Lua, see Terraria Wiki:Lua.
This template is i18n-ready, which means it is easy to localize for different languages. Please see I18n & l10n for templates to learn more.
See Template:Templatedata/l10n for the localization of this template.
Template-info.svg Documentation The documentation below is transcluded from Template:Templatedata/doc. (edit | history)

This template is used to display an enhanced version of the table generated by the <templatedata> tag from the TemplateData extension. It is to be used in the documentation of templates.

Usage

{{ templatedata | <templatedata code> | lang = <language code> | hide = y/yes | description = y/yes | showRaw = y/yes | lazy = y/yes }}

First unnamed parameter

This parameter takes the TemplateData JSON code. It should always be surrounded by <templatedata> and </templatedata>, because this allows the TemplateData code to be edited via the graphical user interface (GUI) accessible by clicking the "Manage TemplateData" button above the editor. If no <templatedata> tag is on the page yet, then the GUI will add it to the end of the documentation text, so it will need to be moved into {{templatedata}} in that case. The template processes the TemplateData JSON code and produces a new, invisible <templatedata> tag, which is "functional" and defines the information used by the Visual Editor. This allows the template to accept slightly more syntax, see below for further information.

lang

ISO 639-1/639-3 code of the language in which to display the output. This affects both the TemplateData information (if defined for the language) and strings like table headings and labels. If this parameter is omitted, it defaults to the wiki's content language (en). (Due to Lua restrictions, it cannot default to the user language, i.e. the user's language preference set in Special:Preferences or the value of the uselang URL parameter.) The language determined by this parameter is used in the "functional" <templatedata> tag; all strings in other languages in the TemplateData JSON code will not be included. (This means that $lang controls the language in which TemplateData information is displayed in the Visual Editor.)

hide

Set this parameter to disable the display of the table, e.g. if a manual documentation of the parameters is more practical. The new, invisible, "functional" <templatedata> tag for the Visual Editor will still be generated.

description

Display the template description (as defined in the TemplateData in $1) above the parameter table; it is not displayed by default. If this parameter is set and no description is defined, an error will be displayed.

showRaw

Use this parameter to append the table generated by the functional <templatedata> tag, in a collapsed wrapper. In this table, the TemplateData information is presented as it is in the Visual Editor. Has no effect if $lazy is set.

lazy

If this parameter is set, then the "functional" <templatedata> tag will not be created. In that case, the <templatedata> tag passed in the first unnamed parameter will be the "functional" TemplateData for the Visual Editor (if the value of $1 does include the tag and is not only the pure JSON code). This means that $lang will be ignored for the Visual Editor (i.e. all strings in all languages will be available in the Visual Editor, and the one that is used there depends on the user language), and that the usual restrictions of TemplateData apply, i.e. the expanded syntax features as described below will not be available.

Notes

  • The syntax allowed in the TemplateData JSON code is less strict with this template. The following elements can be used:
    • Internal links (in the double-bracket format)
    • External links
    • Apostrophes for boldface and italics
    • Certain HTML entities (&lt; and &gt;, &amp;, &quot;, and &nbsp;, as well as all numeric formats such as &#32;)
    • HTML tags (will be removed, but their content will remain)
    • Text enclosed in <noexport> and </noexport> (spaces inside will not be trimmed)
    • The {{p}} template (but not any other templates)
In the Visual Editor, links will be displayed as plain text, bold and italic styling will be removed, <noexport> text will not be displayed at all, and {{p}} will be replaced by quotes.
  • Furthermore, the table displayed by this template includes status-specific styling, language-independent sorting of the status column (by rank rather than by text), linkable parameters (the HTML IDs are templatedata:<parameter name>, e.g. Template:History#templatedata:nocat), and error categorization.