The Policy Hub:TemplateData

Using TemplateBox
Every entity, except inherit that is documented at the TemplateData technical documentation, is supported by TemplateBox. Conversion to JSON is done by a LUA module. The LUA module automatically converts traditionally used parameters as well as the new ones to both, TemplateData, as well as the "historic table", on demand. The "historic table" is the table which was used to show parameter information at Wikimedia Commons before TemplateData was invented.


 * Required parameters
 * (or in its translated form), parameters and their description


 * Translation
 * Avoid LangSwitch. It doesn't work in TemplateData.
 * Append  to the name of any translatable parameter, marked by  in TemplateBox. For example, adding the French translation of the description of parameter 1, you would write  . Supplying only   instead of   will also work. The  -style is recommended because it eases the job for translators. They then recognize the structure behind it without having to consult the documentation.
 * The language code must be the last element. Valid: . Invalid:


 * Naming
 * Both, old names and new names are supported but treated differently if both of them are supplied.
 * For example, while creating the "historic table", if both  and   where supplied, the value for   would be used. For generating TemplateData, the preference is the other way around.


 * Overriding
 * It's possible to override a specific entity, either for the "historic table" or for TemplateData.
 * To override for TemplateData, append a  to the parameter's default name.
 * On the other hand, if you coded something for TemplateData and want to use a link or other markup in the "historic table", use the parameter name without the  or modify that, which should be only used for TemplateData appending.


 * Pay attention:
 * TemplateData does not support parsing Wiki-Markup. Think of it as if it would expand all templates and finally putting a nowiki around all this.
 * When including templates, they must be wrapped them in s, if they should not be expanded (it's, on the other hand, a geeky feature that you can use, if having the expanded content inside TemplateData is exactly what you want).
 * Even though some tags, such as  seem to be rendered as expected, avoid them.


 * Activation:
 * TemplateData can be activated setting the  parameter to   or to  . The former will add a collapsed version of the table; the latter one replaces the "historic table" with the TemplateData table. In both cases, TemplateData is available through the API.

[//commons.wikimedia.org/wiki/Special:ApiSandbox#action=templatedata&format=json&titles=Template%3ATemplateBox /w/api.php?action=templatedata&format=json&titles=Template%3ATemplateBox] ([//commons.wikimedia.org/w/api.php?action=templatedata&format=json&titles=Template%3ATemplateBox raw result], [//commons.wikimedia.org/w/api.php?action=templatedata&format=jsonfm&titles=Template%3ATemplateBox pretty result])
 * Fetching TemplateData (e.g. for TemplateBox itself)


 * Advantages:
 * No type-mixture: Instead of inserting a new content-type, a template can be used.
 * Syntax: Less error-prone compared to editing JSON (without a special editor).
 * Schema: Always valid. TemplateBox always passes a structure matching the requested schema.
 * Flat structure.
 * Prepared for future changes. Adjustments to the LUA module can be made to support future changes. The power of control remains at Commons.
 * Inserting redundant information can be avoided.
 * Template traditionally used at Commons.


 * Issues:
 * Grouping sets is currently not supported in the "historic table". Set labels are not supported to be multilingual (ideas how one could achieve this are truly welcome).


 * Example:

A live example is Template:Information/doc ([//commons.wikimedia.org/w/index.php?title=Template%3AInformation%2Fdoc&diff=102133596&oldid=101526770 edit that enabled TemplateData through TemplateBox], [//commons.wikimedia.org/w/api.php?action=templatedata&format=jsonfm&titles=Template%3AInformation API-result showing the JSON generated by the Lua Module behind TemplateBox])

You can use Special:ExpandTemplates to experiment with how the template will output the template documentation and the Template data section; e.g., copy the example above and paste it into the input text on the Special:ExpandTemplates page; then click on the ok button to see the result.
 * Experimenting: