Module:Tabs

local getArgs = require('Dev:Arguments').getArgs local Tabs = {}

local function toNum(tab) return tonumber(string.sub( tab, 4 )) end

function Tabs.create(frame) local args = getArgs(frame) -- Step 1: create the tabs list local tabslist = mw.html.create('td') -- Step 2: add the mobile label tabslist :tag('span') :addClass('tabsMobile') :wikitext("Navigation: ") -- Step 3: populate the tags local basepage = frame.args['basepagename'] local keys = {} -- ordered keys array for k in pairs(args) do -- get all tabs if k ~= 'category' and k ~= 'basepagename' then table.insert(keys, k)	   end end table.sort(keys, function(a,b) return toNum(a) < toNum(b) end) -- put them in order if args['tab1'] then -- name given for tab1 tabslist:wikitext(, args['tab1'] , ) table.remove( keys, 1 ) -- remove tab1 to have other tabs ready else -- no name for tab1; use default of "info" tabslist:wikitext('Overview') end for i = 1, #keys do -- loop through remaining tabs and append them all tabslist :tag('span') -- add the separator :addClass('tabsMobile') :wikitext(' • ') :done :wikitext( , args[ keys[i] ] ,  ) -- add the tab end -- Step 5: add the tabs list to the container local container = mw.html.create('table') :addClass('tabs') :node(tabslist) return container end

return Tabs