Jump to content

Module:CategoryLinks: Difference between revisions

From Drifters Almanac
Created page with "local p = {} function p.fromDelimited(frame) local input = frame.args[1] or "" local delimiter = frame.args.delimiter or "," local entries = mw.text.split(input, delimiter) local result = {} for _, entry in ipairs(entries) do local trimmed = mw.text.trim(entry) if trimmed ~= "" then table.insert(result, string.format("%s", trimmed, trimmed)) end end return table.concat(result, " • ") en..."
 
m Protected "Module:CategoryLinks" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))
(No difference)

Revision as of 11:55, 6 May 2025

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

local p = {}

function p.fromDelimited(frame)
    local input = frame.args[1] or ""
    local delimiter = frame.args.delimiter or ","
    local entries = mw.text.split(input, delimiter)
    local result = {}

    for _, entry in ipairs(entries) do
        local trimmed = mw.text.trim(entry)
        if trimmed ~= "" then
            table.insert(result, string.format("[[:Category:%s|%s]]", trimmed, trimmed))
        end
    end

    return table.concat(result, " • ")
end

return p