Module:ParseList
From 20R1
Documentation for this module may be created at Module:ParseList/doc
local p = {}
-- Trim whitespace from a string
local function trim(s)
return s:match("^%s*(.-)%s*$")
end
-- Main entry point called from the template
function p.parse(frame)
local args = frame.args
local list = args.list or ""
-- Split by comma (allowing optional spaces around commas)
local items = {}
for item in list:gmatch("[^,]+") do
local cleaned = trim(item)
if cleaned ~= "" then
table.insert(items, cleaned)
end
end
-- Build SMW property assignments
local output = {}
for _, attendee in ipairs(items) do
-- Use [[Property:Attendee::value]] syntax for SMW
table.insert(output, "[[Attendee::" .. mw.text.encode(attendee) .. "]]")
end
-- Join all assignments with newlines
return table.concat(output, "\n")
end
return p
