Module:Multiparamètros
Aparence
La documentation pour ce module peut être créée à Module:Multiparamètros/doc
local mwTrim = mw.text.trim
local p = {}
function p.bruto( frame )
return p._main( frame, function ( item )
return item
end )
end
function p.lim( frame )
return p._main( frame, function ( item )
return '[[' .. ( ( item:sub( 1, 1 ) == ':' ) and item or ':' .. item ) .. ']]'
end )
end
function p.limOtomatico( frame )
return p._main( frame, function ( item )
if item:find( '[', nil, true ) then
return item
else
return '[[' .. ( ( item:sub( 1, 1 ) == ':' ) and item or ':' .. item ) .. ']]'
end
end )
end
function p.categoria( frame )
return p._main( frame, function ( item )
return '[[:Catègorie:' .. item .. '|' .. item .. ']]'
end )
end
function p.utilisator( frame )
return p._main( frame, function ( item )
return '[[Utilisator:' .. item .. '|' .. item .. ']]'
end )
end
function p._main( frame, formatter )
local args = frame:getParent().args
local gras = ( args.gras and args.gras ~= '' )
local items = {}
for i, v in ipairs( args ) do
local item = mwTrim( v )
if item ~= '' then
item = formatter( item )
if gras then
item = '<b>' .. item .. '</b>'
end
items[ #items + 1 ] = item
end
end
local derrierSeparator = args.et and ( ' ' .. args.et .. ' ' )
-- le paramètre "et" peut être défini à vide, exemple : [[Modèle:Module biblio/responsabilité principale]]
if args.et == '' then
derrierSeparator = ' '
end
return mw.text.listToText( items, ', ', derrierSeparator )
end
return p