local p = {}
local getArgs = require('Module:Arguments').getArgs
local function constructCsdTable(args)
local tbl = {}
local current = ''
for k,v in pairs(args) do
if string.match(v, '[GgAaFfCcUuRrTtPp]%d%d?') then
current = v
tbl[current] = {}
else
local arg = mw.text.split(v, '=')
tbl[current][arg[1]] = arg[2]
end
end
return tbl
end
local function build(frame, args)
csdList = constructCsdTable(args)
local requestedReasons = {}
for k,v in pairs(csdList) do
table.insert(requestedReasons, frame:expandTemplate{ title = 'Db-'..string.lower(k), args = {
['raw'] = 'yes',
['rationale'] = v['rationale'] or '',
['nocat'] = 'true' -- for test purposes
}})
--if true then return mw.dumpObject(dbtemplate) end
end
local dbTemplate = frame:expandTemplate{ title = 'Db-meta', args = {
[1] = ' for the following reasons:</b><ul><li>'..table.concat(requestedReasons, '</li><li>') .. '</li></ul> <b>The page may be deleted under any criterion that is valid',
['criterion'] = 'NA',
['temp'] = 'Db-notice-multiple',
-- forward given params to Db-meta
['bot'] = args['bot'] or '',
['blanked'] = args['blanked'] or (csdList['g10'] and 'yes') or '',
['divblank'] = args['divblank'] or (csdList['g10'] and 'yes') or '',
['help'] = args['help'] or '',
}}
return dbTemplate
end
-- Exports
function p.main(frame)
local args = getArgs(frame)
return build(frame, args)
end
function p.dump(frame)
return mw.dumpObject(mw.text.unstripNoWiki(frame.args[1]))
end
return p