Modul:Vörlaag:also
Utsehn
Die Dokumentation für dieses Modul kann unter Modul:Vörlaag:also/Doku erstellt werden
p = {}
function p.main(frame)
local args = p.get_args(frame)
p.bold_linkify_all(args)
local ret
if #args == 2 then
ret = '<div class="disambig-see-also-2">'
else
ret = '<div class="disambig-see-also">'
end
ret = ret .. "''Kiek ok bi'' " .. p.comma_join(args) .. "</div>"
return ret
end
-- Returns a sequence of all the positional arguments passed to the calling
-- template, after filtering out any blank/empty arguments and any arguments
-- that are equal to the current pagename. Ensures that the sequence contains
-- at least one element, even if it's garbage (like "{{{1}}}").
function p.get_args(frame)
local ret = {}
local pagename = frame:preprocess('{{PAGENAME}}')
for index, value in ipairs(frame:getParent().args) do
if value ~= '' and value ~= pagename then
table.insert(ret, value)
end
end
if #ret == 0 then
table.insert(ret, frame:getParent().args[1] or "{{{1}}}")
end
return ret
end
-- Modifies all the values in seq, wrapping them in "'''[[...]]'''".
function p.bold_linkify_all(seq)
for i = 1, #seq, 1 do
seq[i] = "'''[[" .. seq[i] .. "]]'''"
end
end
-- Joins the values in seq with commas, except that the last two elements have
-- both a comma and "and", together with styling that allows users to hide
-- these.
function p.comma_join(seq)
if #seq == 1 then
return seq[1] -- nothing to join
end
local ret = seq[1]
for i = 2, #seq - 1, 1 do
ret = ret .. ", " .. seq[i]
end
return ret .. "<span class='serial-comma'>,</span>" ..
"''<span class='serial-and'> and</span>'' " ..
seq[#seq]
end
return p