| Site News |
|---|
| Warning: This wiki contains spoilers. Read at your own risk! |
Module:PageList
From Fire Emblem Wiki, your source on Fire Emblem information. By fans, for fans.
Creates a list of links to articles. Used in {{Split}} and {{Merge}}.
local getArgs = require("Module:Arguments").getArgs
local p = {}
function p.pagelist(frame)
local pages = getArgs(frame)
local total = 0
for k,v in pairs(pages) do
if type(k) == "number" then
total = total + 1
end
end
local listNamespace = ""
if pages["space"] then
listNamespace = pages["space"]
end
local function makeLink(page)
if listNamespace == "" then
return "[[" .. page .. "]]"
elseif listNamespace == "Template" then
return "{{[[:" .. listNamespace .. ":" .. page .. "|" .. page .. "]]}}"
else
return "[[:" .. listNamespace .. ":" .. page .. "]]"
end
end
local output = ""
if total == 1 then
output = makeLink(pages[1],pageNamespace)
elseif total == 2 then
output = string.format("%s and %s", makeLink(pages[1]), makeLink(pages[2]))
else
i = 1
output = ""
repeat
output = string.format("%s%s, ", output, makeLink(pages[i]))
i = i + 1
until i == total
output = string.format("%sand %s", output, makeLink(pages[i]))
end
return output
end
return p