Module:Image tabber

local function isnotempty(s) return s and s:match( '^%s*(.-)%s*$' ) ~= '' end

local function imagetabby( frame, debugmode ) local args = frame:getParent.args -- find all the nonempty image numbers local imagenums = {} local imagecount = 0 for k, v in pairs( args ) do		local i = tonumber(tostring(k):match( '^%s*image([%d]+)%s*$' ) or '0') if( i > 0 and isnotempty(v) ) then table.insert( imagenums, i ) imagecount = imagecount + 1 end end if debugmode == true then return tostring(imagecount) end table.sort(imagenums) local toRender = "" --local toRender = "{{#tag:tabber|\n" for k,v in pairs(imagenums) do toRender = toRender .. args['caption' .. v] .. "= \n|-|\n" end return frame:callParserFunction{ name = '#tag', args = { 'tabber', toRender } } -- return toRender end

local p = { } function p.tabber( frame ) return imagetabby( frame, false ) end function p.debug( frame ) return imagetabby( frame, true ) end return p