local f = {}
-- Řada
function f.for_nowiki(frame)
local index = tonumber(frame.args.lowest) or f.lowestNonEmpty(frame) -- co když to vrátí string?
local max = tonumber(frame.args.highest) or f.highestNonEmpty(frame) -- co když to vrátí string?
local template = mw.text.unstripNoWiki(frame.args[2])
local result = {}
while index <= max do
local temp = string.gsub(template, '{{{i}}}', '{{{' .. index .. '}}}')
table.insert(result, temp)
index = index + 1
end
return frame:getParent():preprocess(table.concat(result, frame.args[1]))
end
-- Poslední neprázdný
function f.highestNonEmpty(frame)
local t = {}
for key, value in pairs(frame:getParent().args) do
if value ~= '' then
local i
if type(key) == 'string' then
i = tonumber(string.match(key, '[0-9]*$'), 10)
else
i = key
end
if i ~= nil then
t[i] = key
end
end
end
return t[table.maxn(t)]
end
-- První neprázdný
function f.lowestNonEmpty(frame)
local args = frame:getParent().args
local length = 0
for _ in pairs(args) do
length = length + 1
end
local t = {}
for key, value in pairs(args) do
if value ~= '' then
local i
if type(key) == 'string' then
i = tonumber(string.match(key, '[0-9]*$'), 10)
else
i = key
end
if i ~= nil then
t[length - i] = key
end
end
end
return t[table.maxn(t)]
end
-- Poslední prázdný nebo neprázdný
function f.highest(frame)
local t = {}
for key in pairs(frame:getParent().args) do
local i
if type(key) == 'string' then
i = tonumber(string.match(key, '[0-9]*$'), 10)
else
i = key
end
if i ~= nil then
t[i] = key
end
end
return t[table.maxn(t)]
end
-- První prázdný nebo neprázdný
function f.lowest(frame)
local args = frame:getParent().args
local length = 0
for _ in pairs(args) do
length = length + 1
end
local t = {}
for key in pairs(args) do
local i
if type(key) == 'string' then
i = tonumber(string.match(key, '[0-9]*$'), 10)
else
i = key
end
if i ~= nil then
t[length - i] = key
end
end
return t[table.maxn(t)]
end
return f
Poslední aktualizace obsahu: 2024-07-27 15:24:19
Zdroj: Wikipedia (autoři článku Modul:Params)
Licence textu: CC-BY-SA-3.0 Unported
Tento článek byl automaticky přejat z Wikipedie. Na obrázcích nebyly provedeny žádné změny. Obrázky se zobrazují ve zmenšené velikosti (jako miniatury). Kliknutím na obrázek získáte další informace o autorovi a licenci. Byly změněny prvky designu, odstraněny některé odkazy specifické pro Wikipedii (např. odkazy na Editaci a nebo na neexistující hesla) a provedena optimalizace pro rychlé načítání.