模块:Animation
跳到导航
跳到搜索
local VariablesLua = mw.ext.VariablesLua
local cache = mw.ext.LuaCache
local load = function()
local status, result = pcall(function ()
return mw.text.jsonDecode(cache.get('animation__database'))
end)
if status then
return result
else
--fallback
local info = require('Module:Animation/db') -- return table of mw.loadData() has a metatable, can not be used for cache.set and mw.loadData.
cache.set( 'animation__database', mw.text.jsonEncode(info))
return info
end
end;
return {
-- load database for template:animation
-- from template: {{#invoke:animation|loadData}}
loadData = function(frame)
for k,v in pairs(load()) do
VariablesLua.vardefine( 'animation:info:'..k, v )
end
end,
purge = function()
cache.delete( 'animation__database')
end
}
分类:
- 无文档的模块