Site News
Warning: This wiki contains spoilers. Read at your own risk!

Social media: Get in touch with Fire Emblem Wiki on Twitter, Facebook, or Discord!
MediaWiki update: Fire Emblem Wiki has been updated to MediaWiki 1.32.0! If you notice any errors, please report them to a member of our tech support team.

Module:Main

From Fire Emblem Wiki, your source on Fire Emblem information. By fans, for fans.
This documentation is transcluded from Module:Main/doc. To edit this documentation, click here.

Builds the list of articles output by Template:Main. This module allows for an indefinite number of articles to be listed by the template.


local p = {}

function p.main(frame)
	-- Name input for convenience
	local in_args = frame:getParent().args
	-- Start building output
	local args = {}
	local output = ":''Main article"
	
	-- Loop through input: check if labels are entered, and if so,
	-- append them to the link text
	for k, v in pairs(in_args) do
		if type(k) == "number" then
			args[k] = v
		elseif type(k) == "string" and k:sub(1,1) == "l" then
			local i = tonumber(k:sub(2))
			args[i] = args[i] .. "|" .. v
		end
	end
	
	-- Turn the list from above into links, and append to output
	if #args > 1 then
		output = output .. "s: [[" .. mw.text.listToText(args, "]], [[", "]] and [[")
	else
		output = output .. ": [[" .. args[1]
	end
	
	-- Return completed list of articles
	return output .. "]]''"
end

return p