Module:Navbox

local p = {}

local utilsArg = require("Module:UtilsArg")

local DEFAULT_IMG_SIZE = "150x150px"

function p.Main(frame) local args, err = utilsArg.parse(frame:getParent.args, p.Templates.Navbox) local categories = err and err.categoryText or "" if not args.title then return "", categories end local html = mw.html.create("table") :addClass("nomobile navbox mw-collapsible mw-collapsed") :tag("tr") :tag("th") :attr("colspan", 3) :tag("div") :addClass("navbox__header mw-collapsible-toggle") :tag("span") :wikitext(args.title) :done :tag("span") :addClass("navbox__toggle-button") :tag("span") :addClass("navbox__toggle-button-text mw-collapsible-text") :done :done :done :done :done :done for i, row in ipairs(args.rows) do		local tableRow = html:tag("tr") local links = table.concat(row.links or "", " • ") local evenOdd = (i % 2 == 0) and "even" or "odd" if row.group then tableRow :tag("th") :wikitext(row.group) :addClass("navbox__row-header") :done :tag("td") :wikitext(links) :addClass("navbox__row-links navbox__row-links--"..evenOdd) :done end if i == 1 and args.image then local filename = args.image if not string.find(filename, "^File:") then filename = "File:"..filename end local thumbnail = string.format("%s", filename, DEFAULT_IMG_SIZE) tableRow :tag("td") :addClass("navbox__image") :attr("rowspan", #args.rows) :wikitext(thumbnail) end end if args.footer then html:tag("tr") :tag("th") :addClass("navbox__footer") :attr("colspan", 3) :wikitext(args.footer) end local result = tostring(html:done) return result, categories end

p.Templates = { ["Navbox"] = { format = "block", purpose = "Creates navbox templates", categories = {"Metatemplates"}, boilerplate = { separateRequiredParams = false, },		paramOrder = {"title", "image", "group", "links", "footer"}, repeatedGroup = { name = "rows", params = {"group", "links"}, counts = {2, 3, 4, 5, 6, 7}, },		params = { title = { required = true, type = "content", desc = "The navbox title.", trim = true, nilIfEmpty = true, },			image = { type = "wiki-file-name", desc = "A file name, with the  prefix.", trim = true, nilIfEmpty = true, },			group = { type = "string", required = true, desc = "A header for the given row in the navbox.", trim = true, nilIfEmpty = true, },			links = { type = "content", required = true, desc = "A comma-separated list of links for the given row.", trim = true, nilIfEmpty = true, split = true, },			footer = { type = "content", desc = "The navbox footer. Usually contains links to relevant categories.", trim = true, nilIfEmpty = true, },		},	}, }

return p