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 out = mw.html.create('')
for k,v in pairs(csdList) do
local dbtemplate = frame:expandTemplate{ title = 'Db-'..string.lower(k), args = {
['raw'] = 'yes',
['rationale'] = v['rationale'] or '',
['nocat'] = 'true'
}}
--if true then return mw.dumpObject(dbtemplate) end
out:newline():wikitext(dbtemplate)
end
return out
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