Difference between revisions of "Template:Metadata id"
Jump to navigation
Jump to search
m (... and that's not how ifeq works) |
(Add warning for non-empty first parameter) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | <includeonly> | + | <includeonly>{{#if:{{#var:meta_prerelease}}|<!-- Prerelease mode --> |
− | {{#if:{{#var:meta_prerelease}}|<!-- Prerelease mode --> | ||
{{#vardefine:cur_meta|{{#var:meta_{{#var:meta_current_entity}}}}}} | {{#vardefine:cur_meta|{{#var:meta_{{#var:meta_current_entity}}}}}} | ||
{{#vardefine:pre_meta|{{#var:meta_pre_{{#var:meta_current_entity}}}}}} | {{#vardefine:pre_meta|{{#var:meta_pre_{{#var:meta_current_entity}}}}}} | ||
− | {{# | + | {{#switch: {{{1}}} |
+ | | added = | ||
{{change||{{#var:pre_meta}}}} | {{change||{{#var:pre_meta}}}} | ||
{{#vardefine:meta_pre_{{#var:meta_current_entity}}|{{#expr:{{#var:pre_meta}}+1}}}} | {{#vardefine:meta_pre_{{#var:meta_current_entity}}|{{#expr:{{#var:pre_meta}}+1}}}} | ||
− | + | | removed = | |
{{change|{{#var:cur_meta}}|}} | {{change|{{#var:cur_meta}}|}} | ||
{{#vardefine:meta_{{#var:meta_current_entity}}|{{#expr:{{#var:cur_meta}}+1}}}} | {{#vardefine:meta_{{#var:meta_current_entity}}|{{#expr:{{#var:cur_meta}}+1}}}} | ||
− | | | + | | = |
{{#ifeq: {{#var:cur_meta}}|{{#var:pre_meta}} | {{#var:cur_meta}} | {{change|{{#var:cur_meta}}|{{#var:pre_meta}}}} }} | {{#ifeq: {{#var:cur_meta}}|{{#var:pre_meta}} | {{#var:cur_meta}} | {{change|{{#var:cur_meta}}|{{#var:pre_meta}}}} }} | ||
{{#vardefine:meta_{{#var:meta_current_entity}}|{{#expr:{{#var:cur_meta}}+1}}}} | {{#vardefine:meta_{{#var:meta_current_entity}}|{{#expr:{{#var:cur_meta}}+1}}}} | ||
{{#vardefine:meta_pre_{{#var:meta_current_entity}}|{{#expr:{{#var:pre_meta}}+1}}}} | {{#vardefine:meta_pre_{{#var:meta_current_entity}}|{{#expr:{{#var:pre_meta}}+1}}}} | ||
− | | | + | | #default = |
<strong class="error">Invalid parameter to [[Template:Metadata id]] {{{1}}}</strong> | <strong class="error">Invalid parameter to [[Template:Metadata id]] {{{1}}}</strong> | ||
− | + | }} | |
| <!-- Full release mode --> | | <!-- Full release mode --> | ||
{{#vardefineecho:cur_meta|{{#var:meta_{{#var:meta_current_entity}}}}}} | {{#vardefineecho:cur_meta|{{#var:meta_{{#var:meta_current_entity}}}}}} | ||
{{#vardefine:meta_{{#var:meta_current_entity}}|{{#expr:{{#var:cur_meta}}+1}}}} | {{#vardefine:meta_{{#var:meta_current_entity}}|{{#expr:{{#var:cur_meta}}+1}}}} | ||
+ | {{#ifeq: {{{1}}}|||<strong class="error">[[Template:Metadata id]] must be used as <code><nowiki>{{Metadata id|}}</nowiki></code> (with an empty first parameter) for technical reasons</strong>}} | ||
}}</includeonly><noinclude> | }}</includeonly><noinclude> | ||
Used to generate incremental entity metadata IDs. | Used to generate incremental entity metadata IDs. | ||
− | <code> | + | The simplest usage is <code><nowiki>{{Metadata id|}}</nowiki></code>; an empty first parameter is required to avoid caching issues (see [https://phabricator.wikimedia.org/T191574#4607891 T191574]). |
− | Behavior changes if a <code>meta_prerelease</code> variable is defined: the template supports an optional parameter which may be set to | + | <code>cur_meta</code> and <code>pre_meta</code> are local variables, to avoid redundancy. <code>meta_current_entity</code> is defined elsewhere (by <code><nowiki>{{</nowiki>[[Template:Metadata inherit|Metadata inherit]]<nowiki>}}</nowiki></code>), and <code>meta_<var>entity</var></code> and <code>meta_pre_<var>entity</var></code> are accessed via it. Those two values are incremented after this template. |
+ | |||
+ | Behavior changes if a <code>meta_prerelease</code> variable is defined: the template supports an optional parameter which may be set to blank, <code>added</code>, or <code>removed</code>, which can be used to mark metadata entries that were added or removed in the prerelease. | ||
</noinclude> | </noinclude> |
Latest revision as of 06:35, 9 January 2020
Used to generate incremental entity metadata IDs.
The simplest usage is {{Metadata id|}}
; an empty first parameter is required to avoid caching issues (see T191574).
cur_meta
and pre_meta
are local variables, to avoid redundancy. meta_current_entity
is defined elsewhere (by {{Metadata inherit}}
), and meta_entity
and meta_pre_entity
are accessed via it. Those two values are incremented after this template.
Behavior changes if a meta_prerelease
variable is defined: the template supports an optional parameter which may be set to blank, added
, or removed
, which can be used to mark metadata entries that were added or removed in the prerelease.