Checks if the name contains a DLC-suffix and changes it to the according DLC-icon. Then returns a link to name. Used by different templates handling DLC suffixes, such as Template:ItemLink in the example above.
Example
{{ItemLink|Aquatic Mushroom (Aberration)}}
Gives:
-- checks if the name contains a DLC-suffix and changes it to the according DLC-icon. then returns a link to name.
local p = {}
function p.link(name, noDlcIcon)
-- look up DLC icon info for the name with DissectDlcItemName
local tryMatch = require('Module:DissectDlcItemName').tryMatch
local info = tryMatch(name)
if info then
return '[['..name..'|'..info.displayName..']]'.. ((not noDlcIcon) and ' [[File:'..info.dlcIcon..'|16px|link='..info.dlcArticle..'|alt=('..info.dlcArticle..')]]' or '')
end
-- if no dlc was found, use generic approach
local title = mw.title.new(name)
if title == nil then
return 'page not found: ' .. name
end
local link = (#title.nsText > 0) and (title.fullText .. '|' .. title.text) or title.text
return '[['..link..']]'
end
return p