Module:Sandbox/RetroCraft314/test

From Bonkipedia

Documentation for this module may be created at Module:Sandbox/RetroCraft314/test/doc

--[[ {{Infobox|decat = yes|child = yes|title = Keys
    |label1 = Key 1          |data1 = {{#if: {{{key1|}}} | <code>{{{key1}}}</code> }}
    |label2 = Key 2          |data2 = {{#if: {{{key2|}}} | <code>{{{key2}}}</code> }}
    |label3 = Key 3          |data3 = {{#if: {{{key3|}}} | <code>{{{key3}}}</code> }}
  }}]]
  
local p = {}
local args = {}

function p.Keys(frame)    
	if frame == mw.getCurrentFrame() then
        args = frame:getParent().args
    else
        args = frame
    end
	local out = ""
	
    local nums = {}
    for k, v in pairs(args) do
        local num = tostring(k):match('^key([1-9]%d*%a*)$')
        if num then table.insert(nums, k) end
    end
    table.sort(nums)

	for i = 1, #nums do
    	local k, v = nums[i], arr[nums[i]]
		out = out .. ';' .. k .. ':<code>' .. v .. '</code>'
	end
	return out
end

return p