Module:Template display

From Runnina
Jump to navigation Jump to search

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

-- Module:Template display
-- A simplified module to display template documentation boxes.
-- Based on a common pattern used on Wikipedia.

local p = {}

function p.main(frame)
    local args = frame.args
    local template_name = args.template or 'Template'
    local description = args.description or ''
    local parameters = args.parameters or ''
    local style = args.style or ''
    local content = args.content or ''

    local output = '<div class="template-display-box" style="' .. style .. '">'
    output = output .. 'This template uses:'
    output = output .. '<ul>'
    
    -- Add content from the 'content' parameter
    if content and content ~= '' then
        -- Preprocess content to allow Wikitext like * lists and links
        output = output .. frame:preprocess(content)
    end

    output = output .. '</ul>'
    output = output .. '</div>'

    -- Add the main description below the box, if provided
    if description and description ~= '' then
        output = output .. '<p>' .. description .. '</p>'
    end

    return output
end

return p