Module:Subpage tabs

local linkUtil = require('Module:LinkUtil') local p = {} local STANDARD_SUBPAGES = {"Biography", "Physical appearance", "Other realities", "Non-valid material", "Promotion", "Gallery"}

function p.produceTabs(frame) local args = frame:getParent.args local page = args["page"] or args["p"] or frame:preprocess("") local subpages = {} for _, item in pairs(STANDARD_SUBPAGES) do if frame:callParserFunction("#ifexist", page .. "/" .. item, "true") == "true" then subpages[#subpages+1] = item end end local done = false local i = 1 while not done do		if args[i] and args[i] ~= "" then subpages[#subpages+1] = args[i] i = i + 1 else done = true end end local width = 100 / (#subpages + 2) local tabs = "{| class=\"subpage-tabs-main\"\n| class=\"subpage-tabs-tab\" style=\"width:" .. width .. "%\" | " .. linkUtil.stripDab(page) .. "" for i=1, #subpages do tabs = tabs .. "\n| class=\"subpage-tabs-tab\" style=\"width:" .. width .. "%\" | " .. subpages[i] .. "" end tabs = tabs .. "\n| class=\"subpage-tabs-tab\" style=\"width:" .. width .. "%\" | |Talk\n|}" return tabs end

return p