Jump to content

Module:VendorLinks: Difference between revisions

From Drifters Almanac
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, "^(.-)/(.+..."
 
m Protected "Module:VendorLinks" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))
 
(No difference)

Latest revision as of 18:55, 12 May 2025

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