Aller au contenu

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

De Wikiquestia
Aucun résumé des modifications
Balise : Révoqué
Aucun résumé des modifications
Balise : Révoqué
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 charte = frame.args.charte or 'defaut'
local res = ''
local res = ''
local i = 1
local i = 1
Ligne 22 : Ligne 22 :


if res ~= '' then
if res ~= '' then
-- Appel direct au Module:Charte
local couleur = require('Module:Charte').couleur{ args = { charte = charte, type = 'hr' } }
local tableau = string.format(
local tableau = string.format(
'<table class="infobox" style="width:100%%;">%s</table>',
'<table class="infobox" style="width:100%%;">%s</table>',
res
res
)
)
local hr = frame:preprocess(
local hr = string.format('<hr style="background-color: %s;">', couleur)
string.format('<hr style="background-color: {{#invoke:Charte|couleur|charte=%s|type=hr}};">', charte)
 
)
return tableau .. hr
return tableau .. hr
else
else

Version du 26 juin 2025 à 06:29

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
		-- Appel direct au Module:Charte
		local couleur = require('Module:Charte').couleur{ args = { charte = charte, type = 'hr' } }

		local tableau = string.format(
			'<table class="infobox" style="width:100%%;">%s</table>',
			res
		)
		local hr = string.format('<hr style="background-color: %s;">', couleur)

		return tableau .. hr
	else
		return ''
	end
end

return p