Module:InfoboxCharacter

local p = {} local infobox = require("Module:Infobox") local utilsCode = require("Module:UtilsCode") local utilsString = require("Module:UtilsString")

local FIELDS = {{parameter = "age", content = "", caption = "Age", type = "inline"}, {parameter = "race", content = "", caption = "Race", type = "inline"}, {parameter = "gender", content = "", caption = "Gender", type = "inline"}, {parameter = "locations", content = "", caption = "Location(s)", type = "list"}}

function p._Main(frame) local args = frame:getParent.args return p.Main(args) end

function p.Main(args) local fields = FIELDS for key, field in ipairs(fields) do		if not utilsCode.IsEmpty(args[field["parameter"]]) then if field["parameter"] == "locations" then local locationList = "" local firstLocation = true for key2, location in ipairs(utilsString.Explode(args[field["parameter"]], ",")) do					if not firstLocation then firstLocation = false locationList = locationList .. " "					end locationList = "" .. location .. "" end field["content"] = locationList else field["content"] = args[field["parameter"]] end end end return infobox.CreateInfobox(args["name"], {content = args["image"], caption = args["caption"]}, fields) end

return p