« Module:Dates » : différence entre les versions
Apparence
Page créée avec « local p = {} function p.afficherDates(frame) local args = frame:getParent().args local res = '' local i = 1 while args['Date importante ' .. i] or args['Date ' .. i] do local titre = args['Date importante ' .. i] or '' local date = args['Date ' .. i] or '' if titre ~= '' or date ~= '' then res = res .. string.format('<tr><td style="padding-right:1em;"><b>%s</b></td><td>%s</td></tr>', titre, date) end i = i + 1 end if res ~= '' then return... » |
Aucun résumé des modifications |
||
| (27 versions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 3 : | Ligne 3 : | ||
function p.afficherDates(frame) | function p.afficherDates(frame) | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local charte = frame.args.charte or 'defaut' | |||
local couleur = require('Module:Charte').couleur{ args = { charte = charte, type = 'hr' } } | |||
local res = '' | local res = '' | ||
local i = 1 | local i = 1 | ||
while args['Date | while args['Date ' .. i] or args['Événement ' .. i] do | ||
local date = args['Date ' .. i] or '' | local date = args['Date ' .. i] or '' | ||
local evenement = args['Événement ' .. i] or '' | |||
if | if date ~= '' or evenement ~= '' then | ||
res = res .. string.format('<tr>< | res = res .. string.format( | ||
'<tr><th style="text-align:left;">%s</th><td>%s</td></tr>', | |||
date, -- HTML autorisé (ex. : <sup>) | |||
mw.text.nowiki(evenement) -- protégé | |||
) | |||
end | end | ||
i = i + 1 | i = i + 1 | ||
| Ligne 17 : | Ligne 24 : | ||
if res ~= '' then | if res ~= '' then | ||
local tableau = string.format( | |||
' | '<table class="infobox" style="width:100%%;">%s</table>', | ||
res | res | ||
) | ) | ||
local separateur = string.format( | |||
'<div style="width:100%%; display:block; clear:both;">' .. | |||
'<hr style="height:1px; border:0; background-color:%s;">' .. | |||
'</div>', | |||
couleur | |||
) | |||
return tableau .. separateur | |||
else | else | ||
return '' | return '' | ||
Dernière version du 27 juin 2025 à 15:24
La documentation pour ce module peut être créée à Module:Dates/doc
local p = {}
function p.afficherDates(frame)
local args = frame:getParent().args
local charte = frame.args.charte or 'defaut'
local couleur = require('Module:Charte').couleur{ args = { charte = charte, type = 'hr' } }
local res = ''
local i = 1
while args['Date ' .. i] or args['Événement ' .. i] do
local date = args['Date ' .. i] or ''
local evenement = args['Événement ' .. i] or ''
if date ~= '' or evenement ~= '' then
res = res .. string.format(
'<tr><th style="text-align:left;">%s</th><td>%s</td></tr>',
date, -- HTML autorisé (ex. : <sup>)
mw.text.nowiki(evenement) -- protégé
)
end
i = i + 1
end
if res ~= '' then
local tableau = string.format(
'<table class="infobox" style="width:100%%;">%s</table>',
res
)
local separateur = string.format(
'<div style="width:100%%; display:block; clear:both;">' ..
'<hr style="height:1px; border:0; background-color:%s;">' ..
'</div>',
couleur
)
return tableau .. separateur
else
return ''
end
end
return p