Modul:TemplateData: Unterschied zwischen den Versionen
2018-01-25
w>PerfektesChaos (2018-01-23) |
w>PerfektesChaos (2018-01-25) |
||
Zeile 1: | Zeile 1: | ||
local TemplateData = { | local TemplateData = { suite = "TemplateData", | ||
serial = "2018-01-25", | |||
item = 46997995 } | item = 46997995 } | ||
--[=[ | --[=[ | ||
Zeile 1.224: | Zeile 1.224: | ||
TemplateData.failsafe = function ( assert ) | TemplateData.failsafe = function ( assert ) | ||
-- Retrieve versioning and check for compliance | |||
-- Precondition: | |||
-- assert -- string, with required version or "wikidata", | |||
-- or false | |||
-- Postcondition: | |||
-- Returns string with appropriate version, or false | |||
local since = assert | local since = assert | ||
local r | local r | ||
if since == "wikidata" then | if since == "wikidata" then | ||
local item = TemplateData.item | local item = TemplateData.item | ||
since = false | |||
if type( item ) == "number" and item > 0 then | if type( item ) == "number" and item > 0 then | ||
local entity = mw.wikibase.getEntity( string.format( "Q%d", | local entity = mw.wikibase.getEntity( string.format( "Q%d", | ||
Zeile 1.241: | Zeile 1.248: | ||
end | end | ||
end | end | ||
if r then | if not r then | ||
if not since or since <= TemplateData.serial then | |||
r = TemplateData.serial | |||
else | |||
r = false | |||
end | |||
end | end | ||
return r | return r |