Module:Sandbox/Wovenstarlight

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

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

function p.tabs(frame) local args = getArgs(frame) -- Step 1: prep the table local container = mw.html.create('div') :addClass('tabs') -- Step 2: create the tabs list local tabslist = mw.html.create('td') -- Step 3: add the mobile label tabslist :tag('span') :addClass('tabsMobile') :wikitext("Navigation: ") :done -- Step 4: populate the tags local basepage = frame.args['basepagename'] local keys = {} -- ordered keys array for k in pairs(args) do		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) if args['tab1'] then -- name given for tab1 tabslist:wikitext(, args['tab1'] , ) table.remove( keys, 1 ) -- remove it to have other tabs ready else -- no name for tab1; use default of "info" tabslist:wikitext('Info') end -- loop through remaining tabs and append them all for i = 1, #keys do		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 container :tag('table') :tag('tr') :node(tabslist) :done :done :done local overall = mw.html.create local secopen = mw.html.create('section', {selfClosing = true}) :attr('begin', 'tabs') :done local secclose = mw.html.create('section', {selfClosing = true}) :attr('end', 'tabs') :done overall :node(secopen) :node(container) :node(secclose) return overall end

-- The below stuff is from learning, ignore that function p.forloop local i   local result result = ';for\n' for i = 2, 10, 2 do       result = result .. ":i = " .. i .. '\n' end return result end function p.whileloop local i   local result result = ';while\n' i = 2 while i <= 10 do        result = result .. ":i = " .. i .. '\n' i = i + 2 end return result end function p.repeatloop local i   local result result = ';repeat\n' i = 2 repeat result = result .. ":i = " .. i .. '\n' i = i + 2 until i > 10 return result end return p