Module:Nav

--This module is invoked by Template:Nav local p = {} local getArgs = require('Module:Arguments').getArgs local common = require('Module:Common') 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, header, style1 local frame = mw.getCurrentFrame local rows = '' local nHead, nSub = 15, 15 -- number of Headers and Subheaders for iteration -- Initialize args border =   common.setDefault(args.border, '#999') templink = common.setDefault(args.templink, 'Nav') class =    common.setDefault(args.class) style =    common.setDefault(args.style) styleFE =  common.setDefault(args.styleFE) header =   common.setDefault(args.header, 'Header') style1 =   common.setDefault(args.style1) -- Top row if(args.headerFE ~= nil) then rows = rows..' '..args.headerFE..' ' end -- Sections for i = 1, nHead do       if(args['header'..i] ~= nil) then - Section Head rows = rows.. ' '..           ' '..            ''.. ..args['header'..i].... ' '..           ' '            - Section Content if(args['content'..i] ~= nil) then rows = rows..' '..args['content'..i]..' ' else rows = rows..'\n{|width=100% cellpadding=0 cellspacing=0' for j = 1, nSub do                   if(args['subheader'..i..'-'..j] ~= nil) then if(j == 1) then rows = rows..'\n|-\n!style="width:15%; '                       else                            rows = rows..'\n|-\n!style="width:15%; border-top: 1px solid #001866; ' end rows = rows..common.setDefault(args['substyle'..i..'-'..j], style1).. '"| '..args['subheader'..i..'-'..j]..                       '\n|style="padding: 3px; border-top: 1px solid '..border..'; text-align: left"|\n'                        ..common.setDefault(args['subcontent'..i..'-'..j])                    end                end                rows = rows..'\n|}'            end            if(args['note'..i] ~= nil) then                rows = rows..                ''.. args['note'..i]..' '           end            rows = rows..'  '        end    end    -- Final output    out =     '\n'..    ' '..    ' '..    frame:expandTemplate{ title = 'Tnav', args = { 'Template:'..templink, fontcolor = '' } }..    ..header....    ' '..    ' '..    rows..    '  '    return out end return p --