Module:ListLinks: Difference between revisions
Appearance
mNo edit summary |
mNo edit summary |
||
| Line 2: | Line 2: | ||
function p.fromDelimited(frame) | function p.fromDelimited(frame) | ||
local raw = frame:getParent().args[1] or "" | |||
mw.log("Raw input: " .. raw) -- Logs to Special:Log/Scribunto | |||
local delimiter = frame:getParent().args.delimiter or "," | |||
local list = mw.text.split(raw, delimiter) | |||
local output = {} | |||
table.insert(output, '<ul style="margin-left: 1em;">') | |||
for _, item in ipairs(list) do | |||
item = mw.text.trim(item) | |||
if item ~= "" then | |||
table.insert(output, string.format("<li>Item: %s</li>", item)) | |||
end | |||
end | |||
table.insert(output, '</ul>') | |||
return table.concat(output, "\n") | |||
end | end | ||
return p | return p | ||
Revision as of 04:40, 23 April 2025
Documentation for this module may be created at Module:ListLinks/doc
local p = {}
function p.fromDelimited(frame)
local raw = frame:getParent().args[1] or ""
mw.log("Raw input: " .. raw) -- Logs to Special:Log/Scribunto
local delimiter = frame:getParent().args.delimiter or ","
local list = mw.text.split(raw, delimiter)
local output = {}
table.insert(output, '<ul style="margin-left: 1em;">')
for _, item in ipairs(list) do
item = mw.text.trim(item)
if item ~= "" then
table.insert(output, string.format("<li>Item: %s</li>", item))
end
end
table.insert(output, '</ul>')
return table.concat(output, "\n")
end
return p