Module:Noticebox

Module documentation[view][edit][history][purge]
This documentation is transcluded from Module:Noticebox/doc. Changes can be proposed in the talk page.
Function list
L 5 — p._main
L 43 — p.main

This module is exclusively used by other Lua modules but has the same functionality as Template:Noticebox.


require('strict')

local p = {}

function p._main(args)
    local container = mw.html.create('table')
    container
            :addClass('noticebox ' .. (args.class or ''))
            :css({
        ['width'] = '820px',
        ['background'] = '#333',
        ['border'] = '3px solid ' .. (args.bordercolor or '#444'),
        ['border-left-width'] = '10px',
        ['border-radius'] = '8px',
        ['margin'] = '0 auto 10px',
        ['vertical-align'] = 'middle'
    })

    local row = container:tag('tr')

    if args.image and args.image ~= '' then
        local imageWidth = args['image-width'] or args['image_width'] or '40px'
        local imageClass = args['image-class'] or args['image_class'] or ''

        row:tag('td')
           :css({['width'] = '50px', ['padding'] = '0'})
           :wikitext(string.format('[[File:%s|%s|center|class=notpageimage %s|link=]]',
                args.image, imageWidth, imageClass))
    end

    row:tag('td')
       :css({
        ['color'] = args.color or '#fff',
        ['background'] = 'transparent',
        ['vertical-align'] = 'middle',
        ['padding-left'] = '10px'
    })
       :wikitext(args.content or args[1] or 'Content here')

    return tostring(container)
end

function p.main(frame)
    local args = require('Module:Arguments').getArgs(frame)

    return p._main(args)
end

return p