Module:Tabber

From JoJo's Bizarre Encyclopedia - JoJo Wiki
Revision as of 15:29, 7 August 2024 by Vish (talk | contribs)
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,
        },
    }

    return tabberUtils.tabs(tabData, options)
end

return p