Modul:RubrikContainer

Aus Star Citizen Wiki

Die Dokumentation für dieses Modul kann unter Modul:RubrikContainer/Doku erstellt werden

local p = {}

local arguments = require( 'Module:Arguments' )
local args = {}

-- Container Output
function p.output( frame )
    args = arguments.getArgs( frame )

    local section = mw.html.create( 'div' )
    section
        :addClass( 'category-container' )

    if args[ 'content' ] == nil or string.len( args[ 'content' ] ) == 0 then
    section
        :addClass( 'no-content' )
    end

    if args[ 'image' ] == nil or string.len( args[ 'image' ] ) == 0 then
    section
        :addClass( 'no-image' )
    end

    local heading = mw.html.create( 'h2' )
    heading
        :wikitext( args[ 'head_content' ] )

    section:node( heading )

    local contentDiv = mw.html.create( 'div' )

    if args[ 'content' ] ~= nil then
        local textContainer = mw.html.create( 'div' )

        textContainer
            :addClass( 'category-content-container' )
            :wikitext( args[ 'content' ] )

        contentDiv:node( textContainer )
    end

    if args[ 'image' ] ~= nil then
        local imageContainer = mw.html.create( 'div' )

        local imageContain = ''
        if args[ 'image_contain' ] ~= nil then 
            imageContain = 'image-contain' 
        end

        if args[ 'image_class' ] ~= nil then 
            imageContain = imageContain .. ' ' .. args[ 'image_class' ]
        end

        imageContainer
            :addClass( 'category-image-container' )
            :wikitext( '[[' .. args[ 'image' ] .. '|alternativtext=' .. ( args[ 'image_alt' ] or '' ) .. '|rahmenlos|800px|link=' .. ( args[ 'image_link' ] or '' ) .. '|class=' .. imageContain .. ']]' )

        contentDiv:node( imageContainer )
    end

    section:node( contentDiv )

    return tostring( section )
end

return p