Modul:Navbox with striping

Belgekirina modulê[biafirîne]
-- Proof-of-concept for automatic striping
local p = {}

local Navbox = require('Module:Navbox')

function p.navbox(frame)
	local args = frame:getParent().args

	local listnums = {}
	local listcount = 0
	local t = {}

	for k,v in pairs(args) do
		if type(k) == 'string' and k:match('^lîste[0-9][0-9]*$') then
			if( v and v ~= '') then
				listcount = listcount + 1
				listnums[listcount] = mw.ustring.gsub(k,'^lîste([0-9][0-9]*)$', '%1')
			end
		elseif type(k) == 'string' and k:match('^kom[0-9][0-9]*$') then
			-- skip for now, processed below
		elseif( v and v ~= '') then
			t[k] = v
		end
    end
	local function lcomp(n1, n2)
		return (tonumber(n1) or 0) < (tonumber(n2) or 0)
	end
	table.sort(listnums, lcomp)
	for i = 1,listcount do
		t['lîste' .. i] = args['lîste' .. listnums[i]]
		if( args['kom' .. listnums[i]] ~= nil and args['kom' .. listnums[i]] ~= '') then
			t['kom' .. i] = args['kom' .. listnums[i]]
		end
	end
	
	return Navbox._navbox(t)

end

return p