Module:List
Jump to navigation
Jump to search
This is the main module for the following templates:
local p = {}
local h = {}
local Util = {
args = {
parse = require("Module:Util/args/parse"),
split = require("Module:Util/args/split"),
}
}
function p.Main(frame)
local args, err = Util.args.parse(frame:getParent().args, p.Templates.List)
local items = args.entries
if items == nil or #items == 0 then
return "", err
elseif #items == 1 then -- assume list items are delimited by commas or asterisks instead of pipes
items = Util.args.split(items[1])
end
local html = mw.html.create("ul"):addClass("plainlist")
for i, item in ipairs(items) do
html:tag("li"):wikitext(item)
end
return tostring(html), err
end
p.Templates = {
List = {
desc = "Renders each list entry on a separate line without any list markers such as bullets or numbers",
format = "inline",
params = {
["..."] = {
name = "entries",
placeholder = "entry",
type = "content",
desc = "List items. Can be any wikitext.",
trim = true,
nilIfEmpty = true,
},
},
},
}
return p