Modul:CountryData: Razlika med redakcijama

Izbrisana vsebina Dodana vsebina
Nova stran z vsebino: local p = {} local function getcontents(frame,country,params) return frame:expandTemplate({title="Country data "..country;args=params}) end function p.gettable(frame,cou...
 
m posodobitev
Vrstica 1:
local p = {}
local mostUsed = mw.loadData('Modul:CountryData/summary')
 
local function getcontents(frame,country,params)
return frame:expandTemplate({title="Country data "..country;args=params})
end
 
function p.getcachedtable(frame, country, params)
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('Modul:CountryData/cache' .. mostUsed.pages[country])
if cache.data[country] then return cache.data[country] end
end
-- if not in cache
return p.gettable(frame, country, params)
end
 
Vrstica 9 ⟶ 22:
--If not a valid data template, return empty table
local bool, s = pcall(getcontents,frame,country,params or {})
if bool and (string.find(s,"^%{%{ *%{%{%{1") or string.find(s,"^%{%{safesubst: *%{%{%{1"))
then
--Replace parameter delimiters with arbitrary control characters