Module:Navbox
Appearance
Documentation for this module may be created at Module:Navbox/doc
local p = {}
p.navbox = function(frame, args)
local args = args or frame:getParent().args
local title = args.title or "Title"
local above = args.above or "Above"
local below = args.below or "Below"
args[1] = "Group 1"
args[2] = "+ Item 1"
args[3] = "+ Item 2"
local html = ([[<nowiki>
<div class="navbox">
<table class="navbox-inner">
<tr>
<th class="navbox-title" scope="col" colspan="3">
<div>%s</div>
</th>
</tr>
]]):format(title)
if above ~= "" then
html = html..([[
<tr>
<td class="navbox-abovebelow" colspan="3">
<div>%s</div>
</td>
</tr>
]]):format(above)
end
local groupEnd = [[<!-- End group -->
</div>
</td>
</tr>
]]
local i = 1
local inGroup = false
while args[i] ~= nil do
local arg = args[i]
i = i + 1
mw.log(arg)
if arg:sub(1, 2) == "+ " then
html = html..mw.text.trim(arg:sub(3)).." "
else
if inGroup then
html = html..groupEnd
end
html = html..([[
<tr>
<th scope="row" class="navbox-group">%s</th>
<td class="navbox-list1 navbox-list navbox-odd" style="width:100%%;padding:0px;margin:0px">
<div><!-- Start group -->
]]):format(arg)
inGroup = true
end
end
if inGroup then
html = html..groupEnd
end
if below ~= nil then
html = html..([[
<tr>
<td class="navbox-abovebelow" colspan="3">
<div>%s</div>
</td>
</tr>
]]):format(below)
end
html = html..[[
</table>
</div>
</nowiki>
]]
return html
end
return p