Module:InfoboxEmote

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

local FIELDS = {{parameter = "shortcut", content = "", caption = "Shortcut", type = "inline"}, {parameter = "location", content = "", caption = "Location(s)", type = "inline"}, {parameter = "use", content = "", caption = "Use(s)", type = "inline"}}

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

function p.Main(args) local fields = FIELDS -- Setting image local image = "" for key, field in ipairs(fields) do		if not utilsCode.IsEmpty(args[field["parameter"]]) then if field["parameter"] == "location" then field["content"] = h.FormatLocations(args["location"]) else field["content"] = args[field["parameter"]] end end end return infobox.CreateInfobox(args["name"], {content = image, caption = args["caption"]}, fields) end

function h.FormatLocations(locations) local locationList = "" local firstLocation = true for key2, location in ipairs(utilsString.Explode(locations, ",")) do		if not firstLocation then firstLocation = false locationList = locationList .. " "		end locationList = "" .. location .. "" end return locationList end

return p