« Module:Infobox coursdeau » : différence entre les versions
De WikiPerche
Aucun résumé des modifications Balise : Révocation manuelle |
Aucun résumé des modifications |
||
| Ligne 2 : | Ligne 2 : | ||
local p = {} | local p = {} | ||
-- Renvoie la valeur nettoyée, ou nil si absente/vide | |||
local function clean(v) | |||
if v == nil then return nil end | |||
v = mw.text.trim(tostring(v)) | |||
if v == '' then return nil end | |||
return v | |||
end | |||
-- Ajoute une ligne seulement si la valeur existe ; renvoie toujours l'infobox | |||
local function addRow(box, label, value) | |||
value = clean(value) | |||
if value then | |||
box:addRow(label, value) | |||
end | |||
return box | |||
end | |||
function p.main(frame) | function p.main(frame) | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local headerStyle | |||
local headerStyle = 'background-color:' .. (clean(args.headerstyle) or 'lightskyblue') .. ';' | |||
local titleStyle = 'background-color:' .. (clean(args.titlestyle) or 'lightskyblue') .. ';' | |||
headerStyle = | local box = capiunto.create{ | ||
title = clean(args.title), | |||
titleStyle = titleStyle, | |||
headerStyle = headerStyle, | |||
} | |||
if clean(args.image) then | |||
box:addImage(args.image, clean(args.caption)) | |||
end | end | ||
return | addRow(box, 'Code SANDRE', args.codesandre) | ||
addRow(box, 'Longueur', args.longueur) | |||
addRow(box, 'Communes traversées', args.communestraversees) | |||
box:addHeader('Hydrographie') | |||
addRow(box, 'Source', args.source) | |||
addRow(box, '· Localisation', args.localisationsource) | |||
addRow(box, '· Altitude', args.altitudesource) | |||
addRow(box, 'Confluence', args.confluence) | |||
addRow(box, '· Localisation', args.pointdeconfluence) | |||
addRow(box, 'Bassin collecteur', args.bassincollecteur) | |||
return box | |||
end | end | ||
return p | return p | ||
Version du 8 octobre 2026 à 15:30
La documentation pour ce module peut être créée à Module:Infobox coursdeau/doc
local capiunto = require 'capiunto'
local p = {}
-- Renvoie la valeur nettoyée, ou nil si absente/vide
local function clean(v)
if v == nil then return nil end
v = mw.text.trim(tostring(v))
if v == '' then return nil end
return v
end
-- Ajoute une ligne seulement si la valeur existe ; renvoie toujours l'infobox
local function addRow(box, label, value)
value = clean(value)
if value then
box:addRow(label, value)
end
return box
end
function p.main(frame)
local args = frame:getParent().args
local headerStyle = 'background-color:' .. (clean(args.headerstyle) or 'lightskyblue') .. ';'
local titleStyle = 'background-color:' .. (clean(args.titlestyle) or 'lightskyblue') .. ';'
local box = capiunto.create{
title = clean(args.title),
titleStyle = titleStyle,
headerStyle = headerStyle,
}
if clean(args.image) then
box:addImage(args.image, clean(args.caption))
end
addRow(box, 'Code SANDRE', args.codesandre)
addRow(box, 'Longueur', args.longueur)
addRow(box, 'Communes traversées', args.communestraversees)
box:addHeader('Hydrographie')
addRow(box, 'Source', args.source)
addRow(box, '· Localisation', args.localisationsource)
addRow(box, '· Altitude', args.altitudesource)
addRow(box, 'Confluence', args.confluence)
addRow(box, '· Localisation', args.pointdeconfluence)
addRow(box, 'Bassin collecteur', args.bassincollecteur)
return box
end
return p
