Aller au contenu

Module:Dates

De Wikiquestia

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 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
		local tableau = string.format(
			'<table class="infobox" style="width:100%%;">%s</table>',
			res
		)
		local hr = frame:preprocess(
			string.format('<hr style="background-color: {{#invoke:Charte|couleur|charte=%s|type=hr}};">', charte)
		)
		return tableau .. hr
	else
		return ''
	end
end

return p