Module:Infobox

local p = {}

local Franchise = require("Module:Franchise") local utilsArg = require("Module:UtilsArg") local utilsMarkup = require("Module:UtilsMarkup") local utilsString = require("Module:UtilsString") local utilsTable = require("Module:UtilsTable")

function p.Main(frame) local templateName = "Infobox "..frame:getParent:getTitle local args, err, categories local templateSpec = p.Templates[templateName] if templateSpec then args, err = utilsArg.parse(frame:getParent.args, templateSpec) else args = frame:getParent.args end categories = err and err.categoryText or "" if args.name and args.name ~= "" then categories = categories.."" end if args.caption and args.caption ~= "" then categories = categories.."" end return categories end

function p.Games(frame) local games = frame.args[1] if games == nil or games == "" or utilsMarkup.containsLink(games) then return games end games = utilsString.trim(frame.args[1]) games = utilsString.split(frame.args[1]) games = utilsTable.map(games, Franchise.link) games = utilsTable.compact(games) games = utilsMarkup.list(games) return games end

local templateSpec = function(args) local singular = args.singular local plural = args.plural local params = args.params local productionParams = args.productionParams local imageSuchAs = args.imageSuchAs

local spec = { format = "block", purpose = string.format("Infobox for %s.", plural, string.lower(plural)), categories = {"Infobox Templates"}, boilerplate = { separateRequiredParams = false, },		paramOrder = {"name", "image", "caption"}, params = { name = { desc = " Name to use in the infobox header. Defaults to . In general, this parameter should be omitted unless the title requires italics. ", type = "content", },			image = { desc = string.format("An image to represent the %s, such as %s.", singular, imageSuchAs), type = "wiki-file-name", },			caption = { desc = "A caption for the image.", type = "content", }		},	}	for i, param in ipairs(params or {}) do		spec.params[param.name] = param table.insert(spec.paramOrder, param.name) end for i, param in ipairs(productionParams or {}) do		spec.params[param.name] = param table.insert(spec.paramOrder, param.name) end return spec end

local released = { name = "released", desc = "Release date(s) of the film. Use Template:Release.", type = "content", }

p.Templates = { ["Infobox Film"] = templateSpec({		singular = "film",		plural = "films",		imageSuchAs = "a release poster or a DVD cover",		params = {			{				name = "director",				desc = "The director(s) of the film.",				type = "content",			},			{				name = "producer",				desc = "The producer(s) of the film.",				type = "content",			},			{				name = "country",				desc = "Country or countries of production.",				},			released,		}	}), ["Infobox Television"] = templateSpec({		singular = "television",		plural = "television",		imageSuchAs = "the series' logo or title card",		params = {			{				name = "basedOn",				type = "string",				desc = "Comma separated list of games that the series is based on.",				enum = Franchise.enum,				trim = true,				split = true,			},			{				name = "seasons",				type = "content",				desc = "Number of seasons.",			},			{				name = "episodes",				type = "content",				desc = "Number of total episodes.",			},			{				name = "company",				type = "content",				desc = "Production comapany or companies.",			},			{				name = "distributor",				type = "content",				desc = "Distributor(s) of the television series.",			},			released,		}	}) }

return p