Módulo:PetOutfitsVisualizer: mudanças entre as edições
Ir para navegação
Ir para pesquisar
Sem resumo de edição |
Sem resumo de edição |
||
| Linha 3: | Linha 3: | ||
function p.render(frame) | function p.render(frame) | ||
local outfitsStr = frame.args.outfits or "" | local outfitsStr = frame.args.outfits or "" | ||
local lineBreak = tonumber(frame.args.lineBreak) or 1000 | |||
local container = mw.html.create('div'):addClass('pet-outfit-gallery') | local container = mw.html.create('div'):addClass('pet-outfit-gallery') | ||
local childContainer = mw.html.create('div') | local childContainer = mw.html.create('div') | ||
| Linha 12: | Linha 13: | ||
}) | }) | ||
local line = 0 | |||
for outfitPair in outfitsStr:gmatch("[^;]+") do | for outfitPair in outfitsStr:gmatch("[^;]+") do | ||
local file, caption = outfitPair:match("^%s*(.-)%s*,%s*(.-)%s*$") | local file, caption = outfitPair:match("^%s*(.-)%s*,%s*(.-)%s*$") | ||
| Linha 32: | Linha 34: | ||
childContainer:node(box) | childContainer:node(box) | ||
line = line + 1 | |||
if line % lineBreak == 0 then | |||
childContainer:node(mw.html.create('br')) | |||
end | |||
end | end | ||
end | end | ||
Edição das 18h25min de 19 de agosto de 2025
A documentação para este módulo pode ser criada em Módulo:PetOutfitsVisualizer/doc
local p = {}
function p.render(frame)
local outfitsStr = frame.args.outfits or ""
local lineBreak = tonumber(frame.args.lineBreak) or 1000
local container = mw.html.create('div'):addClass('pet-outfit-gallery')
local childContainer = mw.html.create('div')
:addClass('pet-outfit-gallery-child')
:css({
display = 'flex',
flexWrap = 'wrap',
gap = '10px'
})
local line = 0
for outfitPair in outfitsStr:gmatch("[^;]+") do
local file, caption = outfitPair:match("^%s*(.-)%s*,%s*(.-)%s*$")
if file then
local box = mw.html.create('div')
:addClass('gallerybox')
-- Imagem
local imgDiv = mw.html.create('div')
:css({ textAlign = 'center' })
:wikitext(string.format('[[File:%s]]', file))
box:node(imgDiv)
-- Texto/legenda
local textDiv = mw.html.create('div')
:addClass('gallerytext')
:css({ textAlign = 'center', marginTop = '4px' })
:wikitext(caption or "")
box:node(textDiv)
childContainer:node(box)
line = line + 1
if line % lineBreak == 0 then
childContainer:node(mw.html.create('br'))
end
end
end
container:node(childContainer)
return tostring(container)
end
return p