Moduł:Drzewa link: Różnice pomiędzy wersjami

Z Nonsensopedii, polskiej encyklopedii humoru
M
M (czeki czeki)
Linia 13: Linia 13:
}
}
local args = tools.getArgs(frame)
local args = tools.getArgs(frame)
local cat
for k, v in pairs(args) do
local namespace
if expectedArgs[k] ~= nil then
local namespace = expectedArgs[k]
else
return k .. ': ' .. v
end
end
assert(#pairs(args) == 1, 'linkCat() przyjmuje 1 argument, podano ' .. #pairs(args))
assert(#pairs(args) == 1, 'linkCat() przyjmuje 1 argument, podano ' .. #pairs(args))
if args['1'] ~= nil then
if expectedArgs[k] ~= nil then namespace = expectedArgs[k]
else cat = v end
lookup = args['1']
local cat = expectedArgs[lookup.split(':')[1].split(' – ')[0].lower()]
if cat ~= nil then cat = expectedArgs[cat.split(':')[1].split(' – ')[0].lower()] end
return namespace .. ', ' .. cat
else
local cat = expectedArgs[args]
end
return 'cat ' + cat
end
end



Wersja z 16:09, 30 lis 2020


local p = {}
local tools = require('Moduł:Narzędzia')

function p.linkCat(frame)
	local expectedArgs = {
		['główna']='główna', 
		['pliki']='pliki', 
		['nonnews']='nonnews', 
		['słownik']='cytaty', 
		['cytaty']='cytaty', 
		['poradniki']='poradniki', 
		['nonźródła']='nonźródła'
	}
	local args = tools.getArgs(frame)
	local cat
	local namespace
	assert(#pairs(args) == 1, 'linkCat() przyjmuje 1 argument, podano ' .. #pairs(args))
	if expectedArgs[k] ~= nil then namespace = expectedArgs[k]
	else cat = v end
	if cat ~= nil then cat = expectedArgs[cat.split(':')[1].split(' – ')[0].lower()] end
	return namespace .. ', ' .. cat
end

return p