Module:DatasetLoader
Appearance
Documentation for this module may be created at Module:DatasetLoader/doc
-- Module:DatasetLoader
-- Central loader for Data: JSON assets via JsonConfig or mw.loadData, cached per render
local loader = {}
-- Returns a Lua table for the named dataset, or {} on failure
function loader.get(name)
-- Try JsonConfig extension first
if mw.ext and mw.ext.data and mw.ext.data.get then
local ok, data = pcall(mw.ext.data.get, name)
if ok and data then
return data
end
end
-- Fallback to mw.loadJsonData for Data: namespace
if mw.loadJsonData then
local ok2, data2 = pcall(mw.loadJsonData, 'Data:' .. name .. '.json')
if ok2 and data2 and type(data2) == 'table' then
return data2
end
end
-- Ultimate fallback: empty table
return {}
end
return loader