We are actively looking for staff to help us build the wiki. If you are interested please join our Discord server and apply.
Module:InfoboxModuleTest: Difference between revisions
Jump to navigation
Jump to search
m (Testing) |
mNo edit summary |
||
| Line 22: | Line 22: | ||
end | end | ||
result = result .. '[[File:' .. imageName .. '.png|24px|link=]] [[' .. item .. ']]' | |||
result = result .. '[[File:' .. imageName .. '.png|24px|link=]] ' .. item | |||
-- add a separator if not the last item | -- add a separator if not the last item | ||
Revision as of 09:32, 29 June 2024
Documentation for this module may be created at Module:InfoboxModuleTest/doc
-- Module:InfoboxTestModule
local p = {}
function p.displayFoundIn(frame)
local foundIn = frame.args[1]
local items = mw.text.split(foundIn, ',')
local result = ""
-- if there are no items, add "Nothing" as a placeholder
if #items == 0 then
items = {"Nothing"}
end
for i, item in ipairs(items) do
item = mw.text.trim(item)
-- generate an image name from the item name by replacing spaces with underscores
local imageName = string.gsub(item, " ", "_")
if item == "Nothing" then
imageName = "X"
end
result = result .. '[[File:' .. imageName .. '.png|24px|link=]] [[' .. item .. ']]'
-- add a separator if not the last item
if i < #items then
result = result .. ' '
end
end
return result
end
return p