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

Social media: If you would like, please join our Discord server, and/or follow us on Twitter or Tumblr!

Engage info: As the game has only recently released, we lack much key information. Please help add any info that you can.


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 = ""; i = ""
	-- Loop through input
	for k, v in pairs(in_args) do
		if type(k) == "number" then --if the field is a number
			if args[k] == nil then --if the sub-table has not been made
				args[k] = {}
			-- changes any pipe magic words into pipe characters, and underscores to spaces
			v = v:gsub("{{!}}", "|"):gsub("_", " ")
			args[k][1] = v:match("^[^|]+") -- sets input as link before pipe
			if args[k][2] == nil then -- if display text has not been set
				--[[ sets display text as link text
				replaces # in display with §
				only displays characters after a pipe set in the link
				removes / at the start or end of a link]]
				args[k][2] = v:gsub(" *# *", " § ", 1):match("[^\|]+$"):gsub("^/", ""):gsub("/$", "")
		elseif type(k) == "string" and k:sub(1,1) == "l" then -- if field is "l#", the only other type that should be used
			i = tonumber(k:sub(2))
			if args[i] == nil then --if the sub-table has not been made
				args[i] = {}
			args[i][2] = v
	for k, v in pairs(args) do -- assembles links
		args[k] = "[[" .. args[k][1] .. "|''<wbr>" .. args[k][2] .. "<wbr>'']]"
	-- Turns the list from above into links, and appends to output
	if #args == 1 then
		output = output .. args[1]
	elseif #args == 2 then
		output = output .. table.concat(args, "'' and ''")
		output = output .. mw.text.listToText(args, "'', ''", "'', and ''")
	-- Return completed list of articles
	return output

return p