Module:Tabber

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

-- Implements Template:Tabs Hero. function p.hero(frame) local args = getArgs(frame, {   wrappers = {      'Template:Tabs Hero'    }  }) local hero = args[1] or mw.title.getCurrentTitle.baseText -- Use if no page is given. local subpage = function( page ) return hero .. '/' .. page end local custom = function( number ) if args['custom' .. number] then return subpage( args['custom' .. number] ) end end local tabs = { ['this'] = args['this'], ['link1'] = hero, ['name1'] = 'Hero', ['link2'] = subpage( 'Guide' ), ['name2'] = 'Strategy', ['link3'] = subpage( 'Counters' ), ['name3'] = 'Counters', ['link4'] = subpage( 'Equipment' ), ['name4'] = 'Equipment', ['link5'] = subpage( 'Gear' ), ['name5'] = 'Gear',

['link6'] = subpage( 'Talents' ), ['name6'] = 'Talents',

['link7'] = subpage( 'Relics' ), ['name7'] = 'Relics', ['link8'] = subpage( 'Responses' ), ['name8'] = 'Responses', ['link9'] = subpage( 'Sounds' ), ['name9'] = 'Sounds', ['link10'] = subpage( 'Animations' ), ['name10'] = 'Animations', ['link11'] = subpage( 'Lore' ), ['name11'] = 'Lore', ['link12'] = custom( '1' ), ['name12'] = args['custom1'], ['link13'] = custom( '2' ), ['name13'] = args['custom2'], ['link14'] = subpage( 'Old Abilities' ), ['name14'] = 'Old Abilities', ['link15'] = subpage( 'Changelogs' ), ['name15'] = 'Changelogs', ['link16'] = subpage( 'Bugs' ), ['name16'] = 'Known Bugs', } return p._main( tabs ) end

-- Implements Template:Tabber. function p.main(frame) local args = getArgs(frame, {   wrappers = {      'Template:Tabber'    }  }) return p._main( args ) end

function p._main( args ) local current_page = args['this'] or mw.title.getCurrentTitle.prefixedText

local rows = {} for n=1,15 do   if args['link' .. n] then -- Use the link as the name if none is given. local name = args['name' .. n] or args['link' .. n]     if args['link' .. n] == current_page then -- The active tab. table.insert( rows, string.format( ' %s ', name ) ) else -- The inactive tabs. local link = string.format( '%s', args['link' .. n], name ) table.insert( rows, string.format( ' %s ', link ) ) end end end -- The separator is used for the space between two tabs. local separator = '\n \n' -- The tail fills the space between the last tab and the end of the line. local tail = ' ' return string.format( ' \n%s\n%s\n ', table.concat( rows, separator ), tail ) end

return p