From WikiChip
Difference between revisions of "Module:comptable"

(Created page with "local p = {} function p.main_header(frame) if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args else origArgs = frame end...")
 
Line 11: Line 11:
 
      
 
      
 
     for i = 1, 30 do
 
     for i = 1, 30 do
     local val = origArgs['' .. i]
+
     local val = origArgs[i]
 
if not val then break end
 
if not val then break end
 
if string.find(val, ":") then
 
if string.find(val, ":") then

Revision as of 05:19, 22 August 2017

Documentation for this module may be created at Module:comptable/doc

local p = {}

function p.main_header(frame)
    if frame == mw.getCurrentFrame() then
        origArgs = frame:getParent().args
    else
        origArgs = frame
    end
    
    local r = ''
    
    for i = 1, 30 do
    	local val = origArgs[i]
		if not val then break end
		if string.find(val, ":") then
			r = r .. string.gsub(val, "(%d+):(%a+)", '<th colspan="%1">%2</th>')
		else
			r = r .. '<th>' .. val .. '</th>'
		end
	end

	return r
end

return p