Module:Bandeau de source
La documentation pour ce module peut être créée à Module:Bandeau de source/doc
local p = {}
function p.build(frame)
local args = {}
--local argsParent = frame:getParent().args
for k, v in pairs({ frame.args, frame:getParent().args }) do
--Paramètres vides interprétés par Lua
--for cle, val in pairs(argsParent) do
for cle, val in pairs(v) do
if val ~= '' then
args[cle] = mw.text.trim(val)
end
end
end
return p._build(args)
end
function p._build(args)
local bannerType = args[1] or ''
local source = args['source'] or 'source ?'
local link = args['lien'] or ''
local image = args['image'] or 'bandeau de source - defaut.png'
local text = args['texte'] or ''
local bannerText = ''
if bannerType:lower() == 'fin' then
bannerText = 'Fin des informations basées sur ' .. source .. '.'
else
bannerText = 'Les informations suivantes se basent sur ' .. source
if text == 'vide' then
bannerText = bannerText .. '.'
elseif text == 'contradiction' then
bannerText = bannerText .. ' et sont contredites par les sources officielles.'
elseif text == 'avant-première' then
bannerText = bannerText .. ' et peuvent être inexactes ou contenir des \'\'spoilers\'\'.'
elseif text == 'semi' then
bannerText = bannerText .. ' et peuvent être contredites par les sources officielles.'
else
bannerText = bannerText .. ' et n\'ont pas été confirmées par des sources officielles.'
end
end
return mw.html.create( 'div' )
:addClass( 'avt-source-banner' )
:tag( 'div' )
:addClass( 'avt-source-banner-img' )
:wikitext( '[[Fichier:' .. image .. '|x25px|link=' .. link .. '|alt=]]' )
:done()
:tag( 'p' )
:addClass( 'avt-source-banner-text' )
:wikitext( bannerText )
:allDone()
end
return p