Aller au contenu

Module:Infobox

Cha vient éd Wikipedia

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

-- Module:Infobox (version simplifiée pour pcd.wikipedia)

local p = {}

function p.infobox(frame)
    local args = frame:getParent().args
    
    local root = mw.html.create('div')
        :addClass('infobox')
        :css({
            border = '1px solid #aaa',
            padding = '0.5em',
            width = '300px',
            ['background-color'] = '#f9f9f9'
        })

    -- Titre
    if args.titre then
        root:tag('div')
            :css({
                ['font-weight'] = 'bold',
                ['text-align'] = 'center',
                ['font-size'] = '120%',
                ['margin-bottom'] = '0.5em'
            })
            :wikitext(args.titre)
    end

    -- Image
    if args.image then
        root:tag('div')
            :css('text-align', 'center')
            :wikitext('[[File:' .. args.image .. '|250px]]')
    end

    -- Paramètres libres
    for k, v in pairs(args) do
        if k ~= 'titre' and k ~= 'image' and v ~= '' then
            root:tag('div')
                :css('margin-top', '0.3em')
                :wikitext("''' " .. k .. " : ''' " .. v)
        end
    end

    return tostring(root)
end

return p