Module:Sandbox

local p = {}

function split(str, pattern) local out = {} local i = 1 local split_start, split_end = string.find(str, pattern, i)   while split_start do        out[#out+1] = string.sub(str, i, split_start - 1) i = split_end + 1 split_start, split_end = string.find(str, pattern, i)   end out[#out+1] = string.sub(str, i)   return out end

function p.outputAvailabilityCollapsed (frame) local data = frame.args[1] local availabilityTable = split( data, "," ) local availabilityList = "" local mainAvailability = "" for k, avail in ipairs(availabilityTable) do       if k == 1 then mainAvailability = frame:expandTemplate{ title = "Availability", args = { avail } } else availabilityList = availabilityList .. frame:expandTemplate{ title = "Availability", args = { avail } } end end local availabilityOutput = frame:expandTemplate{ title = "User:SuperHamster/Sandbox/Teal", args = { mainAvailability, availabilityList } }

return availabilityOutput end

return p