This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing.
localp={}localgetArgs=require("Module:Arguments").getArgslocalyn=require("Module:Yesno")localcfg=mw.loadData('Module:If preview/configuration')p.pvwc=p.pvwcorpackage.loaded["Module:If preview/preview warning counter"]orrequire("Module:If preview/preview warning counter")--[[mainThis function returns either the first argument or second argument passed tothis module, depending on whether the page is being previewed.]]functionp.main(frame)localargs=getArgs(frame)ifcfg.previewthenreturnargs[1]or''elsereturnargs[2]or''endend--[[pmainThis function returns either the first argument or second argument passed tothis module's parent (i.e. template using this module), depending on whether itis being previewed.]]functionp.pmain(frame)returnp.main(frame:getParent())endlocalfunctionwarning_text(warning)returnmw.ustring.format(cfg.warning_infrastructure,cfg.templatestyles,warning)endfunctionp._warning(args)localwarning=args[1]andargs[1]:match('^%s*(.-)%s*$')or''ifwarning==''thenreturnwarning_text(cfg.missing_warning)endifnotcfg.previewthenreturn''endifyn(args['consolewarning'])thenmw.addWarning('['..p.pvwc.incr()..'] '..(args[1]orcfg.missing_warning))endreturnwarning_text(warning)end--[[warningThis function returns a "preview warning", which is the first argument markedup with HTML and some supporting text, depending on whether the page is being previewed.]]-- function p.warning(frame)-- mw.addWarning(frame.args[1] or cfg.missing_warning)-- return p._warning(frame.args)-- end--[[warning, but for pass-through templates like {{preview warning}}]]functionp.pwarning(frame)localargs=getArgs(frame)returnp._warning(args)end--[[Does both mw.addWarning and preview warning]]functionp.warn(text)iftext==nilortext==""thenreturn""endmw.addWarning('['..p.pvwc.incr()..'] '..text)returnp._warning({text})end--[[Console warning]]functionp.consoleWarning(frame)localargs=getArgs(frame)mw.addWarning('['..p.pvwc.incr()..'] '..(args[1]orcfg.missing_warning))return''endreturnp