Module:TNT: Difference between revisions
From Test Wiki
Content deleted Content added
m 1 revision imported Tags: Mobile edit Mobile web edit |
MacFan4000 (talk | contribs) No edit summary Tags: Manual revert Reverted |
||
| Line 100: | Line 100: | ||
end |
end |
||
local numOnly = true |
|||
local params = {} |
local params = {} |
||
local paramOrder = {} |
local paramOrder = {} |
||
| Line 114: | Line 113: | ||
end |
end |
||
if name then |
if name then |
||
if ( |
|||
(type(name) ~= "number") |
|||
and ( |
|||
(type(name) ~= "string") |
|||
or not string.match(name, "^%d+$") |
|||
) |
|||
) then |
|||
numOnly = false |
|||
end |
|||
params[name] = newVal |
params[name] = newVal |
||
table.insert(paramOrder, name) |
table.insert(paramOrder, name) |
||
| Line 129: | Line 119: | ||
-- Work around json encoding treating {"1":{...}} as an [{...}] |
-- Work around json encoding treating {"1":{...}} as an [{...}] |
||
| ⚫ | |||
if numOnly then |
|||
| ⚫ | |||
end |
|||
local json = mw.text.jsonEncode({ |
local json = mw.text.jsonEncode({ |
||
params=params, |
params=params, |
||
paramOrder=paramOrder, |
paramOrder=paramOrder, |
||
description=data.description |
description=data.description |
||
}) |
}) |
||
| ⚫ | |||
if numOnly then |
|||
| ⚫ | |||
end |
|||
return json |
return json |
||
| Line 170: | Line 156: | ||
-- Give helpful error to thirdparties who try and copy this module. |
-- Give helpful error to thirdparties who try and copy this module. |
||
if not mw.ext or not mw.ext.data or not mw.ext.data.get then |
if not mw.ext or not mw.ext.data or not mw.ext.data.get then |
||
error( |
error('Missing JsonConfig extension; Cannot load https://commons.wikimedia.org/wiki/Data:' .. dataset) |
||
Cannot load https://commons.wikimedia.org/wiki/Data:%s. |
|||
See https://www.mediawiki.org/wiki/Extension:JsonConfig#Supporting_Wikimedia_templates''']], dataset)) |
|||
end |
end |
||