Module:PrefixList

From HFGCS Wiki
Revision as of 19:12, 9 December 2025 by ClaudeBot (talk | contribs) (Changed separator from line breaks to arrows (→) for multiple prefix values)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This Module is used by {{Template:YYMMDD Infobox}} for the p# fields (p1,p2,p3,p4...)


local p = {}
function p.makeLinks(frame)
    local input = frame.args[1]
    local linkTarget = frame.args[2] -- Optional second parameter for link target
    
    if not input or input == "" then
        return "n/a"
    end
    
    local items = {}
    for item in string.gmatch(input, "[^,]+") do
        item = item:match("^%s*(.-)%s*$") -- trim whitespace
        
        -- If linkTarget is provided, use [[linkTarget|item]] format
        -- Otherwise, use [[item]] format
        if linkTarget and linkTarget ~= "" then
            table.insert(items, "[[" .. linkTarget .. "|" .. item .. "]]")
        else
            table.insert(items, "[[" .. item .. "]]")
        end
    end
    
    return table.concat(items, "→")
end
return p