Jump to content

Module:VendorLinks

From Drifters Almanac
Revision as of 18:54, 12 May 2025 by Mildew (talk | contribs) (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 -- Extract only the vendor name from the subpage local _, name = string.match(item, "^(.-)/(.+...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:VendorLinks/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
            -- Extract only the vendor name from the subpage
            local _, name = string.match(item, "^(.-)/(.+)$")
            name = name or item  -- fallback if not a subpage
            table.insert(output, string.format('<li>[[%s|%s]]</li>', item, name))
        end
    end
    table.insert(output, '</ul>')

    return table.concat(output, "\n")
end

return p