« Module:Configurations » : différence entre les versions
De Infothèque
Autres actions
Page créée avec « local p = {} function p.main(frame) local args = frame:getParent().args local titre = args['titre'] if not titre or titre == '' then titre = 'Configurations disponibles' end local columns = { { key = 'processeur', label = 'Processeur' }, { key = 'ram', label = 'Mémoire' }, { key = 'stockage', label = 'Stockage' }, { key = 'graphics', label = 'Carte graphique' }, { key = 'autres', label = 'Autr... » |
m A protégé « Module:Configurations » ([Modifier=Autoriser uniquement les administrateurs] (infini) [Renommer=Autoriser uniquement les administrateurs] (infini)) |
(Aucune différence)
| |
Version du 13 août 2026 à 17:34
La documentation pour ce module peut être créée à Module:Configurations/doc
local p = {}
function p.main(frame)
local args = frame:getParent().args
local titre = args['titre']
if not titre or titre == '' then
titre = 'Configurations disponibles'
end
local columns = {
{ key = 'processeur', label = 'Processeur' },
{ key = 'ram', label = 'Mémoire' },
{ key = 'stockage', label = 'Stockage' },
{ key = 'graphics', label = 'Carte graphique' },
{ key = 'autres', label = 'Autres' },
}
local rows = {}
local i = 1
while true do
local variante = args['variante' .. i]
if not variante or variante == '' then
break
end
local row = { variante = variante }
for _, col in ipairs(columns) do
row[col.key] = args[col.key .. i] or ''
end
table.insert(rows, row)
i = i + 1
end
if #rows == 0 then
return ''
end
local usedColumns = {}
for _, col in ipairs(columns) do
for _, row in ipairs(rows) do
if row[col.key] ~= '' then
table.insert(usedColumns, col)
break
end
end
end
local header = '! Variante'
for _, col in ipairs(usedColumns) do
header = header .. ' !! ' .. col.label
end
local body = {}
for _, row in ipairs(rows) do
local line = "|-\n|\n'''" .. row.variante .. "'''\n"
for _, col in ipairs(usedColumns) do
line = line .. '|\n' .. row[col.key] .. '\n'
end
table.insert(body, line)
end
local out = '<div class="ith-config-wrap">\n'
.. '{| class="wikitable sortable mw-collapsible ith-config-table"\n'
.. '|+ ' .. titre .. '\n'
.. header .. '\n'
.. table.concat(body)
.. '|}\n'
.. '</div>'
return out
end
return p