Template:TemplateData: Difference between revisions
m (Fixup revision 18117) |
(Improve display of custom format) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{Doc}} | {{Doc}} | ||
<onlyinclude><includeonly><!-- | <onlyinclude><includeonly><!-- | ||
-->{{#vardefine:templateData-convert|{{#expr:not{{WsBool|{{{noConvert|}}}}}}}}}<!-- | |||
-->{{#ifexpr:{{#if:{{{1|}}}|1|not{{WsBool|{{#var:templateData-continue}}}}or{{WsBool|{{{noConvert|}}}}}}}|<!-- | -->{{#ifexpr:{{#if:{{{1|}}}|1|not{{WsBool|{{#var:templateData-continue}}}}or{{WsBool|{{{noConvert|}}}}}}}|<!-- | ||
--><p>Do not use named parameter for <code>1</code> ... <code>x</code>. The first Parameter will be automatically marked as <code>1</code>, the second as <code>2</code> and so on.</p> | --><p>Do not use named parameter for <code>1</code> ... <code>x</code>. The first Parameter will be automatically marked as <code>1</code>, the second as <code>2</code> and so on.</p><!-- | ||
--> | |||
{{(!}} class="wikitable sortable" style="width: 100%;" | {{(!}} class="wikitable sortable" style="width: 100%;" | ||
{{!}}- | {{!}}- | ||
Line 10: | Line 12: | ||
! style="width: 10%;" scope="col" {{!}} Status | ! style="width: 10%;" scope="col" {{!}} Status | ||
{{!}}- | {{!}}- | ||
{{# | {{#if:{{{params|}}}|{{{params}}}|{{{1}}}}} | ||
{{{1}}} | |||
{{!)}} | {{!)}} | ||
<p>See [[Template:TemplateData]] and [[Template:TemplateData/entry]] for more information about the parameter list and [[Template:TemplateData/entry#Data Dictionary Notation (DDN) for types|DDNCode]] for more information about types and the DDN Notation</p><!-- | <!-- | ||
-->{{#if:{{{format|}}}|<!-- | |||
--><dl><!-- | |||
--><dt style="float: left; margin-right: 0.5em;">Format:</dt><!-- | |||
--><dd><!-- | |||
-->{{#switch:{{{format}}}<!-- | |||
-->| block | inline =<!-- | |||
--><span class="oo-ui-iconWidget oo-ui-iconElement-icon oo-ui-icon-template-format-{{{format}}}" style="margin-right: 0.25em; background-color: transparent;"></span><!-- | |||
-->''{{ucfirst:{{{format}}}}}''<!-- | |||
-->| #default =<!-- | |||
--><span class="oo-ui-iconWidget oo-ui-iconElement-icon oo-ui-icon-settings" style="margin-right: 0.5em;"></span><!-- | |||
-->''Custom<nowiki>:</nowiki>'' <!-- | |||
-->{{#if:{{#pos:{{{format}}}|<nowiki/> | |||
<nowiki/>}}|{{#tag:pre|{{{format}}}}}<!-- | |||
-->|<code>{{#tag:nowiki|{{{format}}}}}</code><!-- | |||
-->}}<!-- | |||
-->}}<!-- | |||
--></dd><!-- | |||
--></dl><!-- | |||
-->}}<!-- | |||
--><p>See [[Template:TemplateData]] and [[Template:TemplateData/entry]] for more information about the parameter list and [[Template:TemplateData/entry#Data Dictionary Notation (DDN) for types|DDNCode]] for more information about types and the DDN Notation</p><!-- | |||
-->}}<!-- | -->}}<!-- | ||
-->{{#ifeq:{{#var:templateData-convert}}|1<!-- | -->{{#ifeq:{{#var:templateData-convert}}|1<!-- | ||
-->|{{#ifeq:{{WsBool|{{{partial|}}}}}|0<!-- | -->|{{#ifeq:{{WsBool|{{{partial|}}}}}|0<!-- | ||
-->|{{#if:{{#var:templateData-params}}<!-- | -->|{{#vardefine:templateData-continue}}<!-- | ||
-->{{#if:{{#var:templateData-params}}<!-- | |||
-->|<nowiki/> | -->|<nowiki/> | ||
<div class="{{#ifeq:{{WsBool|{{{debug|}}}}}|0|wds-is-hidden|mw-collapsible mw-collapsed" style="display: flow-root;}}"><!-- | <div class="{{#ifeq:{{WsBool|{{{debug|}}}}}|0|wds-is-hidden|mw-collapsible mw-collapsed" style="display: flow-root;}}"><!-- | ||
-->{{# | -->'''Test of raw TemplateData output''':<!-- | ||
--><div class="mw-collapsible-content"><!-- | |||
-->{{#vardefine:templateData-JSON| | |||
{{(}} | {{(}} | ||
"params": {{(}}{{#var:templateData-params}} | {{#if:{{{desc|}}}|"description": {{#invoke:Json|encode|{{{desc}}}}}}}<!-- | ||
{{)}} | -->{{#if:{{{format|}}}|{{#if:{{{desc|}}}|, | ||
"|"}}format": {{#invoke:Json|encode|{{{format}}}}}}}<!-- | |||
-->{{#if:{{{desc|}}}{{{format|}}}|, | |||
"|"}}params": {{#if:{{#var:templateData-params}}|{{(}} | |||
{{#var:templateData-params}} | |||
{{)}}|{{(}}{{)}}}} | |||
{{)}} | {{)}} | ||
}}</div><!-- | }}<!-- | ||
-->{{#tag:templatedata|<!-- | |||
-->{{#var:templateData-JSON}}<!-- | |||
-->}}<!-- | |||
--></div><!-- | |||
--></div><!-- | |||
-->{{#ifeq:{{WsBool|{{{debug|}}}}}|1|<!-- | |||
--><div class="mw-collapsible mw-collapsed" style="display: flow-root;"><!-- | |||
-->'''Test of raw TemplateData JSON''':<!-- | |||
--><div class="mw-collapsible-content"><!-- | |||
-->{{#tag:syntaxhighlight|<!-- | |||
-->{{#var:templateData-JSON}}<!-- | |||
-->| lang = "json"<!-- | |||
-->}}<!-- | |||
--></div><!-- | |||
--></div><!-- | |||
-->}}<!-- | |||
-->{{#vardefine:templateData-params}}<!-- | -->{{#vardefine:templateData-params}}<!-- | ||
-->}}<!-- | -->}}<!-- | ||
Line 33: | Line 76: | ||
-->}}<!-- | -->}}<!-- | ||
-->}}<!-- | -->}}<!-- | ||
-->{{#vardefine:templateData-JSON}}<!-- | |||
-->{{#vardefine:templateData-convert}}<!-- | -->{{#vardefine:templateData-convert}}<!-- | ||
--></includeonly></onlyinclude> | --></includeonly></onlyinclude> |
Latest revision as of 19:23, 24 May 2021
Template for creating a unified parameter format for templates
About
Creates a list that displays Template parameter in a unified format.
Parameter
Do not use named parameter for 1
... x
. The first Parameter will be automatically marked as 1
, the second as 2
and so on.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Description | desc
|
The MediaWiki TemplateData description property, ignored if
|
Plaintext | Recommended |
Format | format
|
The MediaWiki TemplateData format string, ignored if
|
FormatString | Recommended |
Entries | 1 params
|
Parameter list
|
1 {Template:TemplateData/entry} | Required |
Partial? | partial
|
Whether this TemplateData block is not the last, ignored if
|
Boolean | Optional |
No Conversion | noConvert
|
If set, other than to 0, prevents MediaWiki TemplateData from being produced. Potentially useful if there are multiple instances of this template on a page but only one should be active. To clarify, this means that this template will not be understood by the VisualEditor.
|
Boolean | Optional |
- Format:
- Custom:
{{_ | ______ = _ }}
See Template:TemplateData and Template:TemplateData/entry for more information about the parameter list and DDNCode for more information about types and the DDN Notation
Creates a table that displays Template parameters in a unified format and emits the equivalent MediaWiki TemplateData.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Description | desc | The [[mw:Help:TemplateData#Description|MediaWiki TemplateData description property]], ignored if <code>noConvert</code> or <code>partial</code> is <code>1</code>. | Content | suggested |
Format | format | The [[mw:Help:TemplateData#Format|MediaWiki TemplateData format string]], ignored if <code>noConvert</code> or <code>partial</code> is <code>1</code>. | Content | suggested |
Entries | 1 params | Parameter list | Content | required |
Partial? | partial | Whether this TemplateData block is not the last, ignored if <code>noConvert</code> is <code>1</code>.
| Boolean | optional |
No Conversion | noConvert | If set, other than to 0, prevents [[mw:Help:TemplateData|MediaWiki TemplateData]] from being produced. Potentially useful if there are multiple instances of this template on a page but only one should be active. To clarify, this means that this template will ''not'' be understood by the VisualEditor.
| Boolean | optional |
Examples
{{#lsth:Template:TemplateData/entry/doc|Examples}}