Модуль:Redirect-multi
Модуль для шаблона {{redirect-multi}}.
local mRedirectHatnote = require('Module:Redirect hatnote')
local mHatList = require('Module:Hatnote list')
local mArguments = require('Module:Arguments')
local mHatnote = require('Module:Hatnote')
local p = {}
function p.redirectMulti (frame)
local args = mArguments.getArgs(frame)
--Get maxArg manually because getArgs and table.maxn aren't friends
local maxArg = 0
for k, v in pairs(args) do
if type(k) == 'number' and k > maxArg then maxArg = k end
end
--Get number of redirects then remove it from the args table
local numRedirects = tonumber(args[1]) or 1
--Manual downshift of arguments; not using table.remove because getArgs is
--gnarly and it's not a sequence anyway
for i = 2, maxArg + 1 do args[i - 1] = args[i] end
--if no arguments past redirects exist, add in a default set
if maxArg - 2 < numRedirects then
local formattedRedirectDisam = {}
local formattedRedirect = {}
for i = 1, numRedirects do
formattedRedirect[i] = '«' .. args[i] .. '»'
formattedRedirectDisam[i] = '[[' .. mHatList.disambiguate(args[i]) .. '|' .. args[i] .. ']]'
end
local text = {
'Запросы',
mHatList.conjList('и', formattedRedirect),
'перенаправляются сюда; см. также другие значения терминов',
mHatList.conjList('и', formattedRedirectDisam) .. '.'
}
return mHatnote.hatnote({table.concat(text, ' '), hide_disambig=1})
end
return mRedirectHatnote._redirect(args, numRedirects)
end
return p