Content deleted Content added
Undid revision 947738882 by 2A01:CB04:4AC:2300:1975:F518:CB7A:FA9 (talk) CLearly not an attempt at sandboxing a change to Module:Data |
simp? |
||
(3 intermediate revisions by one other user not shown) | |||
Line 2:
function mt.__index(t, k)
end▼
return function(frame)
local success, data = pcall(mw.loadData
if not success then
for _,v in ipairs(frame.args) do▼
success, data =
if not success then
error("'" .. k .. "' is not a valid data page")
end
local ty = type(data)
if ty ~= 'table' then
local args = {}
for j = 1, i - 1 do
args[j] = frame.args[j]
end
if frame.args.softfail then
return '<span class="error">[[Category:Pages with failed Module:Data lookups]]Error: Tried to read index "' .. mw.text.nowiki(v) .. '" of mw.loadData("' .. mw.text.nowiki(k) .. '").' .. mw.text.nowiki(table.concat(args, '.')) .. ', which is a ' .. ty .. '</span>'
else
error('Tried to read index "' .. v .. '" of mw.loadData("' .. k .. '").' .. table.concat(args, '.') .. ', which is a ' .. ty)
end
end
local nextdata = data[v]
if nextdata == nil and tonumber(v) then
data = data[tonumber(v)]
else
data = nextdata
end
end
return data
|