Module:TagDetails
From Eco - English Wiki
Documentation
This module is a part of the Template:TagDetails, and is used to generate cards that display information about Tags.
If the template is passed, this module is used with the following Modules:
-- Credit: User:Avaren
local p = {}
-- Grabs args from the parent frame
-- Trims and parses the args into a table, then returns the table
function norm()
local origArgs = mw.getCurrentFrame():getParent().args
local args = {}
for k, v in pairs( origArgs ) do
v = mw.text.trim( tostring( v ) )
if v ~= '' then
args[k] = v
end
end
return args
end
-- build tag list
function p.tagList( args )
local args = norm()
-- check that all necessary arguments are passed correctly
if args.name == nil or args.name == '' then
return '\'name\' must be specified.'
end
local tagName = args.name
local itemData = require( "Module:ItemData" )
local tagList = itemData.tags
local itemList = tagList[tagName]
if (itemList == nil) then
return tagName .. " could not be found in the tag data"
end
local text = ""
text = text .. '<div style="border: 5px outset #A9A9A9; background: #DCDCDC; display:inline-block; width: auto; padding: 10px; margin: 10px; text-align: center; vertical-align: middle;">'
text = text .. '<div class="iconContainer">'
text = text .. '<div class="iconStack">[[File:'..string.gsub(tagName, ' ', '')..'_Icon.png|class=iconWhite|link='..tagName..'Tag]]</div>'
text = text .. '<div class="iconBorder"></div></div>'
text = text .. '<h3>[['..tagName..'Tag]]</h3></div>'
text = text .. '\n\n\nItems with the [['..tagName..']] tag:\n'
for k, item in pairs(itemList) do
text = text .. '<div style="border: 5px outset #A9A9A9; background: #DCDCDC; display:inline-block; width: auto; padding: 10px; margin: 10px; text-align: center; vertical-align: middle;">'
text = text .. '<div class="iconContainer">'
text = text .. '<div class="iconStack">[[File:'..string.gsub(item, ' ', '')..'_Icon.png|class=iconBlue|link='..item..']]</div>'
text = text .. '<div class="iconBorder"></div></div>'
text = text .. '<h3>[['..item..']]</h3></div>'
-- text = text .. '{{IconFrame|file='..item..'_Icon.png|link = '..item..'|text = <h3>[['..item..']]</h3>}}'
end
return text
end
return p