Module:InfoboxList

From FamiWiki

Documentation for this module may be created at Module:InfoboxList/doc

-- Partially adapted from Nookipedia under CC BY-SA 3.0, see authors here: https://nookipedia.com/w/index.php?title=Module:List&action=history
local p = {}

local function getArgs(frame)
    local args = {}
    for key, value in pairs(frame:getParent().args) do
        args[key] = value
    end
    for key, value in pairs(frame.args) do
        args[key] = value
    end
    return args
end

function split(str, pattern)
    local out = {}
    for m in string.gmatch(str, "[^" .. pattern .. "]+") do
      table.insert(out, m)
    end
    return out
end

function p.main(frame)
    local args       = getArgs(frame)
    local listOfList = split( args[1], "," ) or ''
    return p.listFormat(listOfList)
end

function p.listFormat(listOfList)
	local listOf = ''
	for l = 1, #listOfList do
        listOf = listOf .. "<li style=\"list-style: none\">" .. listOfList[l] .. '</li>'
	end
	return listOf
end

return p