Jump to content

Module:Check for deprecated parameters

Permanently protected module
From Wikipedia, the free encyclopedia

-- 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-- on the listlocalp={}localfunctiontrim(s)returns:match('^%s*(.-)%s*$')endlocalfunctionisnotempty(s)returnsandtrim(s)~=''endfunctionp.check(frame)-- create the table of deprecated values and their matching new valuelocalargs=frame.argslocaldep_values={}fork,vinpairs(args)doifk=='ignoreblank'ork=='preview'ork=='deprecated'thenelsedep_values[k]=vendend-- loop over the parent args and see if any are deprecatedlocalvalues={}localignoreblank=isnotempty(frame.args['ignoreblank'])localpargs=frame:getParent().argsfork,vinpairs(pargs)doifignoreblankthenifdep_values[k]andv~=''thentable.insert(values,k)endelseifdep_values[k]thentable.insert(values,k)endendend-- add results to the output tableslocalres={}if#values>0thenlocalpreview=frame.args['preview']or'Page using [['..frame:getParent():getTitle()..']] with deprecated parameter _VALUE_'ifisnotempty(preview)thenpreview=require('Module:If preview')._warning({preview})end-- Kind of dangerous to trust that this is never nil, but I guess it's-- preferable to display that the use of the module is broken rather than-- have some sort of tracking category for pages which have an unknown-- parent tracking template.localcategory=frame.args['category']fork,vinpairs(values)dolocalc=category:gsub('_VALUE_',v)table.insert(res,c)ifv==''then-- Fix odd bug for | = which gets stripped to the empty string-- and breaks category linksv=' 'endlocalp=preview:gsub('_VALUE_','"'..v..'". Replace with "'..dep_values[v]..'".')table.insert(res,p)endendreturntable.concat(res)endreturnp
close