Module:Tabber

From Little Tail Wiki
Revision as of 18:43, 8 February 2025 by Admin (talk | contribs) (Created page with "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)...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump 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