« Module:Liste d'articles par jeu » : différence entre les versions
Page créée avec « local p = {} local abb = require( 'Module:Abréviation' ) function p._build(args) local res = mw.html.create( 'div' ) :addClass( 'infobox avt-infobox' ) local ite… » |
Aucun résumé des modifications |
||
Ligne 13 : | Ligne 13 : | ||
:done() | :done() | ||
noneItem = true | |||
for i = 1, 12 do | for i = 1, 12 do | ||
local game = args['jeu' .. i] | local game = args['jeu' .. i] | ||
Ligne 20 : | Ligne 21 : | ||
local articles = args['articles' .. i] | local articles = args['articles' .. i] | ||
if articles then | if articles then | ||
noneItem = false | |||
local row = mw.html.create('tr') | local row = mw.html.create('tr') | ||
:tag( 'th' ) | :tag( 'th' ) | ||
Ligne 40 : | Ligne 42 : | ||
break | break | ||
end | end | ||
end | |||
if noneItem then | |||
return '' | |||
end | end | ||
Dernière version du 13 janvier 2022 à 17:30
Ce module génère le tableau {{Liste d'articles par jeu}}.
local p = {}
local abb = require( 'Module:Abréviation' )
function p._build(args)
local res = mw.html.create( 'div' )
:addClass( 'infobox avt-infobox' )
local items = mw.html.create( 'table' )
:tag('caption')
:attr({ colspan = '2' })
:wikitext('Articles par jeu')
:done()
noneItem = true
for i = 1, 12 do
local game = args['jeu' .. i]
if game then
game = abb.name( game )
if game and #game > 0 then
local articles = args['articles' .. i]
if articles then
noneItem = false
local row = mw.html.create('tr')
:tag( 'th' )
:attr({ scope = 'row' })
:wikitext( "''[[" .. game .. "]]''" )
:done()
:tag( 'td' )
:tag( 'div' )
:wikitext('\n' .. articles .. '\n')
:done()
:done()
:allDone()
items:node(row)
end
else
break
end
else
break
end
end
if noneItem then
return ''
end
res :node( items )
:allDone()
return tostring(res)
end
function p.build(frame)
local args = {}
local argsParent = frame:getParent().args
for cle, val in pairs(argsParent) do
if val then
args[cle] = mw.text.trim(val)
end
end
return p._build(args)
end
return p