Module:Talent: Difference between revisions
From eSportsAmaze
More actions
Esportsamaze (talk | contribs) Created page with "local p = {} local html = mw.html function p.main(frame) local args = frame:getParent().args local container = html.create('div'):addClass('talent-box') -- Iterate through group1, group2, group3... to keep order for i = 1, 20 do local role = args['group' .. i] local people = args['list' .. i] if role and role ~= "" and people and people ~= "" then -- 1. Create the Group Section local section =..." |
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') | ||
-- Iterate through group1, group2, group3... | -- Iterate through group1, group2, group3... | ||
for i = 1, 20 do | for i = 1, 20 do | ||
local role = args['group' .. i] | local role = args['group' .. i] | ||
| Line 12: | Line 12: | ||
if role and role ~= "" and people and people ~= "" then | if role and role ~= "" and people and people ~= "" then | ||
-- 1. Create | -- 1. Create Section | ||
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') | ||
-- 2. Process | -- 2. Process List | ||
local | local items = mw.text.split(people, ",") | ||
for _, | for _, item in ipairs(items) do | ||
name = mw.text.trim( | -- Split "Name=Image.png" | ||
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 | if name ~= "" then | ||
local chip = grid:tag('div'):addClass('talent-chip') | local chip = grid:tag('div'):addClass('talent-chip') | ||
-- A. | -- A. Determine Image Name | ||
-- | -- If custom image given: use that | ||
-- If not: default to "Name.png" | |||
local fileTarget = customImg or (name .. ".png") | |||
-- Clean up: Ensure "File:" prefix exists | |||
if not mw.ustring.find(fileTarget, "^File:") and not mw.ustring.find(fileTarget, "^Image:") then | |||
fileTarget = "File:" .. fileTarget | |||
end | |||
-- | -- B. Render Image | ||
chip:tag('div'):addClass('talent-img') | chip:tag('div'):addClass('talent-img') | ||
:wikitext('[[ | :wikitext('[[' .. fileTarget .. '|link=|class=talent-avatar-img|50px]]') | ||
-- | -- C. Render Name | ||
chip:tag('div'):addClass('talent-name') | chip:tag('div'):addClass('talent-name') | ||
:wikitext('[[' .. name .. ']]') | :wikitext('[[' .. name .. ']]') | ||
Revision as of 09:42, 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')
-- Iterate through group1, group2, group3...
for i = 1, 20 do
local role = args['group' .. i]
local people = args['list' .. i]
if role and role ~= "" and people and people ~= "" then
-- 1. Create Section
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')
-- 2. Process List
local items = mw.text.split(people, ",")
for _, item in ipairs(items) do
-- Split "Name=Image.png"
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
local chip = grid:tag('div'):addClass('talent-chip')
-- A. Determine Image Name
-- If custom image given: use that
-- If not: default to "Name.png"
local fileTarget = customImg or (name .. ".png")
-- Clean up: Ensure "File:" prefix exists
if not mw.ustring.find(fileTarget, "^File:") and not mw.ustring.find(fileTarget, "^Image:") then
fileTarget = "File:" .. fileTarget
end
-- B. Render Image
chip:tag('div'):addClass('talent-img')
:wikitext('[[' .. fileTarget .. '|link=|class=talent-avatar-img|50px]]')
-- C. Render Name
chip:tag('div'):addClass('talent-name')
:wikitext('[[' .. name .. ']]')
end
end
end
end
return tostring(container)
end
return p