Module:Sandbox/Sameboat/m1

This is an old revision of this page, as edited by Sameboat (talk | contribs) at 08:07, 28 January 2015. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local getArgs = require('Module:Arguments').getArgs

local function makeInvokeFunction(funcName)
	-- makes a function that can be returned from #invoke, using
	-- [[Module:Arguments]].
	return function (frame)
		local args = getArgs(frame, {parentOnly = true})
		return p[funcName](args)
	end
end

local styles = {
	['r1'] = '\n|-\n!style="background:#000;color:#fff;"|',
	['r2'] = '\n!style="background:#000;color:#fff;"|',
	}

local p = {}

p.row = makeInvokeFunction('_row')
 
function p._row(args)
	local row = args[1] or args.row
if row == '1' then row = styles['r1'] else row = styles['r2'] end
	return row
end
 
return p