Module:CountryData/sandbox: Difference between revisions

Content deleted Content added
m Add check for other params in getcachedtable
m Removed protection from "Module:CountryData/sandbox": No longer necessary: Requested at RfPP with 16 transclusions
 
(5 intermediate revisions by 4 users not shown)
Line 2:
local mostUsed = mw.loadData('Module:CountryData/summary')
 
local function getcontents(frame,country,params)
return frame:expandTemplate({title="Country data "..country;args=params})
end
 
function p.getcachedtable(frame, country, params)
if params and next(params) then return p.gettable(frame, country) end
-- Uses mw.loadData to cache data for the most-used templates
country = mostUsed.redirects[country] or country
if params and next(params) then return p.gettable(frame, country, params) end
-- Uses mw.loadData to cache data for the most-used templates
if mostUsed.pages[country] then
local cache = mw.loadData('Module:CountryData/cache' .. mostUsed.pages[country:sub(1,1)])
if cache.data[country] then return cache.data[country] end
end
-- if not in cache
return p.gettable(frame, country, params)
end