Module:RubricContainer

From CLOCKUP WIKI

Documentation for this module may be created at Module:RubricContainer/doc

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' )
    else
    section
        :addClass( 'content' )
    end

	if args[ 'class' ] ~= nil then
		section:addClass( args[ 'class' ] )
	end

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

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

    	section:node( heading )
	end

    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|' .. ( args[ 'image_size' ] or '800px' ) .. '|link=' .. ( args[ 'image_link' ] or '' ) .. '|class=' .. imageContain .. ']]' )

        contentDiv:node( imageContainer )
    end

    section:node( contentDiv )

    return tostring( section )
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.