Module:Sandbox

--This module is invoked by Template:Nav

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

function setDefault(arg, value) if(arg == nil) then arg = value end return arg end

function p.main(frame) args = getArgs(frame) if(pcall(p._main, args)) then return p._main(args) else return ' Error. See Template:Nav for more info. '   end end

function p._main(args) local out, border, templink, class, style, styleFE, headerFE local frame = mw.getCurrentFrame local rows, section = ,  local nHead, nSub = 15, 10 -- number of Headers and Subheaders for iteration -- Initialize args border =   setDefault(args.border, '#999') templink = setDefault(args.templink, 'Nav') class =    setDefault(args.class, '') style =    setDefault(args.style, '') styleFE =  setDefault(args.styleFE, '')

-- Top row if(args.headerFE ~= nil) then rows = rows..'\n!class="'..class..'" style="'..styleFE..'"|'..args.headerFE..'\n|-' end -- Sections for i = 1, nHead do       if(args['header'..i] ~= nil) then if(args['content'..i] ~= nil) then section = section..'\n|-\n| '..args['content'..i]           else for j = 1, nSub do                   if(args['subheader'..i..'-'..j] ~= nil) then if(j == 1) then section = section..'\n|-\n!style="width:15%; '                       else                            section = section..'\n|-\n!style="width:15%; border-top: 1px solid #001866; ' end section = section..setDefault(args['substyle'..i..'-'..j], args.style1).. '"| '..args['subheader'..i..'-'..j]..                       '\n|style="padding: 3px; border-top: 1px solid '..border..'; text-align: left"| '                        ..args['subcontent'..i..'-'..j]                    end                end            end            rows = rows..            '\n|-\n|'..            '\n{|class="collapsible collapsed" width=100% cellspacing=0 cellpadding=0'..            '\n!colspan=2 style="'..setDefault(args['style'..i], args.style1)..'"'..            '| '..args['header'..i]..' '..            section..            '\n|}'        end    end    -- Final output    out =     '{|class="collapsible collapsed" cellspacing=2 cellpadding=0 '..    'style="width: 100%; text-align:center; font-family: times; border:2px solid '..border..'"'..    '\n!style="'..style..'"| '..    frame:expandTemplate{ title = 'Tnav', args = { 'Template:'..templink, fontcolor = '' } }..    ' '..setDefault(args.header, 'Header')..' '.. '\n|-'.. rows.. '\n|}' return out end

return p --