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.loadData for Data: namespace
local ok2, data2 = pcall(mw.loadData, 'Data:' .. name)
if ok2 and data2 then
return data2
end
-- Ultimate fallback: empty table
return {}
end
return loader