Module:Check for unknown parameters

Documentation for this module may be created at Module:Check for unknown parameters/doc

-- This module may be used to compare the arguments passed to the parent-- with a list of arguments, returning a specified result if an argument is-- not on the listlocal p = {}local function isnotempty(s)return s and s:match( '^%s*(.-)%s*$' ) ~= ''endfunction p.check (frame)local args = frame.argslocal pargs = frame:getParent().argslocal ignoreblank = isnotempty(frame.args['ignoreblank'])local knownargs = {}local unknown = 'Found _VALUE_, 'local res = {}-- create the list of known args, and the return stringfor k, v in pairs(args) doif type(k) == 'number' thenv = mw.ustring.gsub(v, '^%s*(.-)%s*$', '%1')knownargs[v] = 1elseif (k == 'unknown' and type(v) == 'string') thenunknown = vendendend-- loop over the parent args, and make sure they are on the listfor k,v in pairs(pargs) doif (knownargs[k] == nil and type(k) == 'string') thenif( (not ignoreblank) or (ignoreblank and isnotempty(v)) ) thenk = mw.ustring.gsub(k, '[^%w\-_ ]', '?')local r = mw.ustring.gsub(unknown, '_VALUE_', k)table.insert(res, r)endendendreturn table.concat(res)endreturn p