Module:Infobox V3/Tableau Ligne données
Apparence
La documentation de ce module est générée par le modèle {{Documentation module}}.
Les éditeurs peuvent travailler dans le bac à sable (créer).
Voir les statistiques d'appel depuis le wikicode sur l'outil wstat et les appels depuis d'autres modules.
local trim = require( 'Module:Outils' ).trim
local function insertNewline( value )
local firstChar = value:sub( 1, 1 )
if firstChar == '*' or firstChar == '#' then
return '\n' .. value
end
return value
end
local p = {}
function p.main( frame )
local args = frame:getParent().args
-- true si args[ 'if' ] non défini, ou chaine non vide
-- false si chaine vide
local argIf = args[ 'if' ] == nil or args[ 'if' ] ~= ''
if not argIf then
return ''
end
local values = {}
for i = 1, 8 do
local value = trim( args[ i ] )
if value then
values[ #values + 1 ] = value
end
end
if #values == 0 then
return ''
end
local tr = mw.html.create( 'tr' )
if args[ 'row-class' ] and args[ 'row-class' ] ~= '' then
tr:addClass( args[ 'row-class' ] )
end
if args[ 'class' ] == 'double' then
local th = mw.html.create( 'th' )
:attr( 'scope', 'row' )
:wikitext( insertNewline( values[ 1 ] ) )
if args[ 'width' ] and args[ 'width' ] ~= '' then
th:css( 'width', args[ 'width' ] .. 'em' )
end
tr:newline():node( th )
else
local td = mw.html.create( 'td' )
:addClass( 'data' )
:wikitext( insertNewline( values[ 1 ] ) )
tr:newline():node( td )
end
for i = 2, #values do
local td = mw.html.create( 'td' )
:addClass( 'data' )
:wikitext( insertNewline( values[ i ] ) )
tr:newline():node( td )
end
return tostring( tr )
end
return p