Module:Tabber

From JoJo's Bizarre Encyclopedia - JoJo Wiki
Jump to navigation Jump to search

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

local p = {}

local tabberUtils = require("Module:TabberUtils")

function p.main(frame)
    local parentArgs = frame:getParent().args
    local args = tabberUtils.parse(parentArgs)

    return p.printTabs(args)
end

function p.printTabs(args)
    local tabData = {}
    for _, tab in ipairs(args.tabs) do
        local tabContent = tab.content
        if tabContent and mw.text.killMarkers(tabContent) == "" then
            tabContent = mw.text.unstripNoWiki(tabContent)
            tabContent = mw.getCurrentFrame():preprocess(tabContent)
        end
        table.insert(tabData, {
            label = tab.tab,
            content = tabContent
        })
    end
    
    local options = {
        align = args.align,
        default = args.default,
        tabOptions = {
            columns = args.columns,
            position = args.position,
            stretch = args.distribution == "stretch",
        },
        contentOptions = {
            fixedHeight = args.position == "bottom",
            alignVertical = args.position == "bottom" and "center" or nil,
        },
        class = args.class,
    }

    return tabberUtils.tabs(tabData, options)
end

return p