Aller au contenu

« Module:Dates » : différence entre les versions

De Wikiquestia
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 1 : Ligne 1 :
local p = {}
local p = {}


function p.afficherComparaison(frame)
function p.afficherDates(frame)
local args = frame:getParent().args
local args = frame:getParent().args
local res = ''
local res = ''
local i = 1
local i = 1


while args['Élément ' .. i] or args['Valeur ' .. i] do
while args['Date ' .. i] or args['Événement ' .. i] do
local titre = args['Élément ' .. i] or ''
local evenement = args['Événement ' .. i] or ''
local valeur = args['Valeur ' .. i] or ''
local date = args['Date ' .. i] or ''


if titre ~= '' or valeur ~= '' then
if evenement ~= '' or date ~= '' then
res = res .. string.format('<tr><td style="padding-right:1em;"><b>%s</b></td><td>%s</td></tr>', titre, valeur)
res = res .. string.format(
'<tr><td style="padding-right:1em;"><b>%s</b></td><td>%s</td></tr>',
mw.text.nowiki(evenement),
mw.text.nowiki(date)
)
end
end
i = i + 1
i = i + 1
Ligne 18 : Ligne 22 :
if res ~= '' then
if res ~= '' then
return string.format(
return string.format(
'<div class="soustitre" style="text-align:center; background-color: #ecf6fb; font-weight: bold; padding: 4px 8px; margin-top: 6px;">Comparaison</div><table class="infobox" style="width:100%%;">%s</table>',
'<div class="soustitre" style="text-align:center; background-color: #ecf6fb; font-weight: bold; padding: 4px 8px; margin-top: 6px;">Dates importantes</div><table class="infobox" style="width:100%%;">%s</table>',
res
res
)
)

Version du 25 juin 2025 à 08:20

La documentation pour ce module peut être créée à Module:Dates/doc

local p = {}

function p.afficherDates(frame)
	local args = frame:getParent().args
	local res = ''
	local i = 1

	while args['Date ' .. i] or args['Événement ' .. i] do
		local evenement = args['Événement ' .. i] or ''
		local date = args['Date ' .. i] or ''

		if evenement ~= '' or date ~= '' then
			res = res .. string.format(
				'<tr><td style="padding-right:1em;"><b>%s</b></td><td>%s</td></tr>',
				mw.text.nowiki(evenement),
				mw.text.nowiki(date)
			)
		end
		i = i + 1
	end

	if res ~= '' then
		return string.format(
			'<div class="soustitre" style="text-align:center; background-color: #ecf6fb; font-weight: bold; padding: 4px 8px; margin-top: 6px;">Dates importantes</div><table class="infobox" style="width:100%%;">%s</table>',
			res
		)
	else
		return ''
	end
end

return p