Zuletzt bearbeitet vor 4 Monaten
von Tim

Modul zur Erstellung von Infoboxen, Siehe Vorlage:Infobox für mehr Informationen


local p = {}

local function infoboxTemplate(frame)
    local args = frame:getParent().args
    local root = mw.html.create('div')
        :addClass('infobox')
        :css('width', '22em')

    if args['title'] then
        root:tag('div')
            :addClass('infobox-title')
            :wikitext(args['title'])
    end
    if args['image'] then
        root:tag('div')
            :addClass('infobox-image')
            :wikitext(string.format('[[Datei:%s|center|%s|%s]]', args['image'], args['image-width'] or '280px',args['image-alt'] or ''))
    end
    if args['subtitle'] then
        root:tag('div')
            :addClass('infobox-subtitle')
            :wikitext(args['subtitle'])
    end

    for i = 1, 50 do
        local label = args['label' .. i]
        local data = args['data' .. i]

        -- Skip the row if label or data is "", "Meter", "Kilogramm", or "[[]]"
        if label and data and label ~= "" and data ~= "" and 
           label ~= "Meter" and data ~= "Meter" and 
           label ~= "Kilogramm" and data ~= "Kilogramm" and 
           label ~= "Liter" and data ~= "Liter" and 
           label ~= "[[]]" and data ~= "[[]]" then

            root:tag('div')
                :addClass('infobox-row')
                :tag('div')
                    :addClass('infobox-label')
                    :wikitext(label)
                :done()
                :tag('div')
                    :addClass('infobox-data')
                    :wikitext(data)
                :done()
        end
    end

    return tostring(root)
end

function p.infobox(frame)
    return infoboxTemplate(frame)
end

return p
Keine Kategorien vergebenBearbeiten