Module:Infobox

local p = {}

local utilsArg = require("Module:UtilsArg")

function p.Main(frame) local infoboxType = frame.args[1] if not infoboxType then error("Infobox type required") end local args, err = utilsArg.parse(p.Templates["Infobox "..infoboxType], frame:getParent.args) local categories = err and err.categoryText or "" if args.name then categories = categories.."" end if args.caption then categories = categories.."" end return categories end

local templateSpec = function(args) local singular = args.singular local plural = args.plural 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(productionParams or {}) do		spec.params[param.name] = param table.insert(spec.paramOrder, param.name) end if productionParams then table.insert(spec.paramOrder, "released") spec.params["released"] = { desc = "Release date(s) of the film. Use Template:Release.", type = "content", }	end return spec end

p.Templates = { ["Infobox Film"] = templateSpec({		singular = "film",		plural = "films",		imageSuchAs = "a release poster or a DVD cover",		productionParams = {			{				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.",				},		}	}), ["Infobox Television"] = templateSpec({		singular = "television",		plural = "television",		imageSuchAs = "the series' logo or title card",		productionParams = {			{				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.",			},		}	}) }

return p