Module:ItemSlot: Difference between revisions
(Created page with "local p = {} function p.main(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...") |
No edit summary |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p. | function p.render(frame) | ||
local args = frame.args | local args = frame.args | ||
Revision as of 05:02, 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 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