Module:FRS notification
Appearance
local p = {}
function p.notification(frame)
local args = frame:getParent().args
local argNums = getArgNums(args, "title")
local out = {}
for index, num in ipairs(argNums) do
num = tostring(num)
out[#out + 1] = frame:expandTemplate{
title = 'User:Yapperbot/FRS notification/content',
args = {
title = args["title" .. num],
rfcid = args["rfcid" .. num],
type = args["type" .. num]
}
}
end
return " " .. mw.text.listToText(out)
end
function getArgNums(args, prefix)
-- Returns a table containing the numbers of the arguments that exist
-- for the specified prefix. For example, if the prefix was 'data', and
-- 'data1', 'data2', and 'data5' exist, it would return {1, 2, 5}.
-- This function is adapted from [[Module:Infobox]], and is released under
-- the Creative Commons Attribution-Share-Alike License 3.0.
-- https://creativecommons.org/licenses/by-sa/3.0/
local nums = {}
for k, v in pairs(args) do
local num = tostring(k):match('^' .. prefix .. '([0-9]%d*)$')
if num then table.insert(nums, tonumber(num)) end
end
table.sort(nums)
return nums
end
return p