Module:Icon: Difference between revisions

Jump to navigation Jump to search
LVL (talk | contribs)
Added kudzu connection alias
LVL (talk | contribs)
Add getCanonicalName function for use by wrapper templates to ensure correct name casing in data attributes
Line 86: Line 86:
     end
     end
     return linkOverrides[iconInfo.name] or iconInfo.name
     return linkOverrides[iconInfo.name] or iconInfo.name
end
-- Returns the canonical display name for a given user input.
-- Used by templates to store the correct casing in data attributes
-- so that Lua modules which do exact string matching receive the right value.
function p.getCanonicalName(frame)
    local name = frame.args[1] or ""
    local lowerName = name:lower()
    if aliases[lowerName] then
        lowerName = aliases[lowerName]
    end
    local iconInfo = iconData[lowerName]
    if not iconInfo then
        iconInfo = legacyItems[lowerName]
    end
    if not iconInfo then
        return name -- fall back to original input if not found
    end
    return iconInfo.name
end
end