Module:InfoboxRace

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

local FIELDS = {{parameter = "locations", content = "", caption = "Location(s)", type = "list"}, {parameter = "notable_members", content = "", caption = "Notable member(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 elseif field["parameter"] == "notable_members" then local memberList = "" local firstMember = true for key2, member in ipairs(utilsString.Explode(args[field["parameter"]], ",")) do					if not firstMember then firstMember = false memberList = memberList .. " "					end memberList = "" .. member .. "" end field["content"] = memberList else field["content"] = args[field["parameter"]] end end end return infobox.CreateInfobox(args["name"], {content = args["image"], caption = args["caption"]}, fields) end

return p