Module:SubpageLinks: Difference between revisions
Appearance
Created page with "local p = {} function p.fromDelimited(frame) local raw = frame.args[1] or "" local delimiter = frame.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 local label local target = item -- If it has a /, treat it as "Name/Zone" → "Na..." |
m Protected "Module:SubpageLinks" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) |
(No difference)
| |
Latest revision as of 18:35, 12 May 2025
Documentation for this module may be created at Module:SubpageLinks/doc
local p = {}
function p.fromDelimited(frame)
local raw = frame.args[1] or ""
local delimiter = frame.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
local label
local target = item
-- If it has a /, treat it as "Name/Zone" → "Name (Zone)"
local base, zone = string.match(item, "^(.-)/(.+)$")
if base and zone then
label = base .. " (" .. zone .. ")"
else
label = item
end
table.insert(output, string.format('<li>[[%s|%s]]</li>', target, label))
end
end
table.insert(output, '</ul>')
return table.concat(output, "\n")
end
return p