Module:ItemSlot: Difference between revisions
No edit summary |
No edit summary |
||
| Line 26: | Line 26: | ||
table.insert(output, imgTag) | table.insert(output, imgTag) | ||
end | end | ||
local result = table.concat(output, "") | |||
local tooltipText = tooltip or filesParam | local tooltipText = tooltip or filesParam | ||
Revision as of 05:06, 27 November 2025
Documentation for this module may be created at Module:ItemSlot/doc
local p = {}
function p.render(frame)
local args = frame.args
local filesParam = args[1] or ""
local linkTarget = args[2]
local tooltip = args[3]
local output = {}
-- Split by comma
for filename in string.gmatch(filesParam, '([^,]+)') do
filename = filename:gsub("^%s*(.-)%s*$", "%1") -- trim spaces
if not filename:lower():match("%.png$") then
filename = filename .. ".png"
end
local imgTag
if linkTarget and linkTarget ~= "" then
imgTag = string.format('[[File:%s|link=%s]]', filename, linkTarget)
else
imgTag = string.format('[[File:%s]]', filename)
end
table.insert(output, imgTag)
end
local result = table.concat(output, "")
local tooltipText = tooltip or filesParam
if tooltip then
result = result .. '<span class="item-tooltip">' .. tooltipText .. '</span>'
end
return '<div class="item-slot">' .. result .. '</div>'
end
return p