Aller au contenu

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

De Wikiquestia
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
Ligne 1 : Ligne 1 :
local p = {}
local p = {}


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


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


if titre ~= '' or date ~= '' then
if titre ~= '' or valeur ~= '' then
res = res .. string.format('<tr><td style="padding-right:1em;"><b>%s</b></td><td>%s</td></tr>', titre, date)
res = res .. string.format('<tr><td style="padding-right:1em;"><b>%s</b></td><td>%s</td></tr>', titre, valeur)
end
end
i = i + 1
i = i + 1
Ligne 18 : Ligne 18 :
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;">Dates importantes</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;">Comparaison</div><table class="infobox" style="width:100%%;">%s</table>',
res
res
)
)
Ligne 27 : Ligne 27 :


return p
return p
--[=[
== 📘 Description ==
Ce module affiche dynamiquement une section « Comparaison » dans une infobox. 
Tu peux l’utiliser pour lister autant de paires Élément/Valeur que tu veux.
== 🔧 Syntaxe ==
{{Infobox V3/Comparaison
| Élément 1 = Taille
| Valeur 1 = 180 cm
| Élément 2 = Poids
| Valeur 2 = 75 kg
}}
== 📥 Paramètres ==
* Élément n — intitulé à afficher à gauche
* Valeur n — valeur correspondante à droite
== 🧩 Exemple pratique ==
* Élément 1 = Longueur
* Valeur 1 = 250 m
* Élément 2 = Largeur
* Valeur 2 = 80 m
== 🔗 Voir aussi ==
* [[Modèle:Infobox V3/Comparaison]]
]=]

Version du 25 juin 2025 à 07:35

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

local p = {}

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

	while args['Élément ' .. i] or args['Valeur ' .. i] do
		local titre = args['Élément ' .. i] or ''
		local valeur = args['Valeur ' .. i] or ''

		if titre ~= '' or valeur ~= '' then
			res = res .. string.format('<tr><td style="padding-right:1em;"><b>%s</b></td><td>%s</td></tr>', titre, valeur)
		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;">Comparaison</div><table class="infobox" style="width:100%%;">%s</table>',
			res
		)
	else
		return ''
	end
end

return p

--[=[
== 📘 Description ==
Ce module affiche dynamiquement une section « Comparaison » dans une infobox.  
Tu peux l’utiliser pour lister autant de paires Élément/Valeur que tu veux.

== 🔧 Syntaxe ==
{{Infobox V3/Comparaison
 | Élément 1 = Taille
 | Valeur 1 = 180 cm
 | Élément 2 = Poids
 | Valeur 2 = 75 kg
}}

== 📥 Paramètres ==
* Élément n — intitulé à afficher à gauche
* Valeur n — valeur correspondante à droite

== 🧩 Exemple pratique ==
* Élément 1 = Longueur
* Valeur 1 = 250 m
* Élément 2 = Largeur
* Valeur 2 = 80 m

== 🔗 Voir aussi ==
* [[Modèle:Infobox V3/Comparaison]]
]=]