Module:RfX template maker
Appearance
This module is used to create RfX templates. Please see {{RfX template maker}} for usage instructions.
-- This module allows people to make templates that display data about current RfA and RfB discussions,
-- without them having to know how to program in Lua.
local data = require('Module:RfX template maker/data')
local p = {}
local function err(msg)
return string.format('<strong class="error">Error: %s.</strong>', msg)
end
function p.main(frame)
local args = frame.args
local template = args.template
if not template then
return err('template not specified')
end
local rfas = data.rfa
local rfbs = data.rfb
local rfxTable
if args.type == 'rfa' then
rfxTable = rfas
elseif args.type == 'rfb' then
rfxTable = rfbs
else
return err('type parameter must be "rfa" or "rfb"')
end
local ret = {}
local renderRow = p.renderRow
for _, t in ipairs(rfxTable) do
local targs = {}
for k, v in pairs(t) do
targs[k] = v
end
ret[#ret + 1] = frame:expandTemplate{title = template, args = targs}
end
return table.concat(ret, '\n')
end
function p.rfacount()
local rfas = data.rfa
if rfas then
return #rfas
else
return 0
end
end
function p.rfbcount()
local rfbs = data.rfb
if rfbs then
return #rfbs
else
return 0
end
end
return p