local p =
-- Ripped from Module:Infobox. TODO: Make a utility module that can do this kind of thinglocal function getArgNums(args, prefix) -- Returns a table containing the numbers of the arguments that exist -- for the specified prefix. For example, if the prefix were to be 'data', and -- 'data1', 'data2', and 'data5' were to exist, it would return . local nums = for k, v in pairs(args) do local num = tostring(k):match('^' .. prefix .. '([1-9]%d*)$') if num then table.insert(nums, tonumber(num)) end end table.sort(nums) return numsend
-- Forked from Module:Unsubst-infobox
local specialParams =
p[''] = function (frame) if not frame.args['$B'] then error(' requires parameter $B (template content)') end
if mw.isSubsting then ---- substing -- Passed args local args = for k, v in pairs(frame:getParent.args) do args[k] = v end
-- Build an equivalent template invocation -- First, find the title to use local titleobj = mw.title.new(frame:getParent:getTitle) local title if titleobj.namespace
0 then -- NS_MAIN title = ':' .. titleobj.text else title = titleobj.prefixedText end
-- Remove empty fields for k, v in pairs(args) do if v
-- Pull aliases local nums = getArgNums(args, '[Ss]ingle ?') for _, num in ipairs(nums) do args['single' .. num] = args['single' .. num] args['single' .. num .. 'date'] = args['single' .. num .. 'date'] or end for k, v in pairs do if args[k] and not args[v] then args[v], args[k] = args[k], nil end end
-- Build the invocation body local ret = ''
ret = mw.ustring.gsub(ret, '%s+\n', '\n')
return ret else -- Not substing -- Just return the "body" return frame.args['$B'] endend
function p.main(frame) local args = require('Module:Arguments').getArgs(frame,) local out = local nums = getArgNums(args, '[Ss]ingle ?') for _, num in ipairs(nums) do out = out .. '\n#
"' .. args['single' .. num] .. '"' local date = args['single' .. num .. 'date'] if date then out = out .. '' .. out .. '\n
' end return outend
return p