On Friday, April 19, 2024 at 10:00 PM New York time, all OpenWiki Project sites will be undergoing scheduled maintenance for about 2 hours. Expect read-only access and brief periods of downtime.

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 p = {}

function p.pagelist(frame)
	local pages = frame:getParent().args
	
	local linkForm = ""
	
	if frame.args["space"] == "template" then
		linkForm = "{{[[Template:%s|%s]]}}"
	else
		linkForm = "[[%s]]"
	end
		
	
	total = 0
	for k,v in pairs(pages) do
		if type(k) == "number" then
			total = total + 1
		end
	end
	
	if total == 1 then
		output = string.format(linkForm, pages[1])
	elseif total == 2 then
		output = string.format(linkForm .. " and " .. linkForm, pages[1], pages[2])
	else
		i = 1
		output = ""
		repeat
			output = string.format("%s" .. linkForm .. ", ", output, pages[i], pages[i])
			i = i + 1
		until i == total
		output = string.format("%sand " .. linkForm, output, pages[i], pages[i])
	end
	return output
end

return p