Module:Talent: Difference between revisions
From eSportsAmaze
More actions
Esportsamaze (talk | contribs) No edit summary |
Esportsamaze (talk | contribs) No edit summary |
||
| Line 6: | Line 6: | ||
local container = html.create('div'):addClass('talent-box') | local container = html.create('div'):addClass('talent-box') | ||
for i = 1, 20 do | for i = 1, 20 do | ||
local role = args['group' .. i] | local role = args['group' .. i] | ||
| Line 12: | Line 11: | ||
if role and role ~= "" and people and people ~= "" then | if role and role ~= "" and people and people ~= "" then | ||
local section = container:tag('div'):addClass('talent-section') | local section = container:tag('div'):addClass('talent-section') | ||
section:tag('div'):addClass('talent-role-header'):wikitext(role) | section:tag('div'):addClass('talent-role-header'):wikitext(role) | ||
local grid = section:tag('div'):addClass('talent-grid') | local grid = section:tag('div'):addClass('talent-grid') | ||
local items = mw.text.split(people, ",") | local items = mw.text.split(people, ",") | ||
for _, item in ipairs(items) do | for _, item in ipairs(items) do | ||
-- Split " | -- Split by "=" | ||
local parts = mw.text.split(item, "=") | local parts = mw.text.split(item, "=") | ||
local name = mw.text.trim(parts[1]) | local name = mw.text.trim(parts[1]) | ||
| Line 26: | Line 23: | ||
if name ~= "" then | if name ~= "" then | ||
local chip = grid:tag('div'):addClass( | -- Decide class based on whether image exists | ||
local chipClass = customImg and 'talent-chip has-img' or 'talent-chip no-img' | |||
local chip = grid:tag('div'):addClass(chipClass) | |||
-- A. | -- A. IF IMAGE EXPLICITLY SET | ||
if customImg then | |||
-- Check for "File:" prefix | |||
if not mw.ustring.find(customImg, "^File:") and not mw.ustring.find(customImg, "^Image:") then | |||
customImg = "File:" .. customImg | |||
end | |||
chip:tag('div'):addClass('talent-img') | |||
:wikitext('[[' .. customImg .. '|link=|class=talent-avatar-img|50px]]') | |||
end | end | ||
-- B. | -- B. NAME (Always shown) | ||
chip:tag('div'):addClass('talent-name') | chip:tag('div'):addClass('talent-name') | ||
:wikitext('[[' .. name .. ']]') | :wikitext('[[' .. name .. ']]') | ||
Revision as of 09:48, 6 February 2026
Documentation for this module may be created at Module:Talent/doc
local p = {}
local html = mw.html
function p.main(frame)
local args = frame:getParent().args
local container = html.create('div'):addClass('talent-box')
for i = 1, 20 do
local role = args['group' .. i]
local people = args['list' .. i]
if role and role ~= "" and people and people ~= "" then
local section = container:tag('div'):addClass('talent-section')
section:tag('div'):addClass('talent-role-header'):wikitext(role)
local grid = section:tag('div'):addClass('talent-grid')
local items = mw.text.split(people, ",")
for _, item in ipairs(items) do
-- Split by "="
local parts = mw.text.split(item, "=")
local name = mw.text.trim(parts[1])
local customImg = parts[2] and mw.text.trim(parts[2])
if name ~= "" then
-- Decide class based on whether image exists
local chipClass = customImg and 'talent-chip has-img' or 'talent-chip no-img'
local chip = grid:tag('div'):addClass(chipClass)
-- A. IF IMAGE EXPLICITLY SET
if customImg then
-- Check for "File:" prefix
if not mw.ustring.find(customImg, "^File:") and not mw.ustring.find(customImg, "^Image:") then
customImg = "File:" .. customImg
end
chip:tag('div'):addClass('talent-img')
:wikitext('[[' .. customImg .. '|link=|class=talent-avatar-img|50px]]')
end
-- B. NAME (Always shown)
chip:tag('div'):addClass('talent-name')
:wikitext('[[' .. name .. ']]')
end
end
end
end
return tostring(container)
end
return p