Module:Error/sandbox
Appearance
From Wikipedia, the free encyclopedia
This is the module sandbox page for Module:Error (diff).
See also the companion subpage for test cases (run).
See also the companion subpage for test cases (run).
Warning This Lua module is used on approximately 52,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them.
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.
This module implements {{Error }}. It creates an html message with class "error". Please, see the documentation page there for usage instructions.
See also
[edit ]The above documentation is transcluded from Module:Error/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (edit | run) pages.
Add categories to the /doc subpage. Subpages of this module.
Editors can experiment in this module's sandbox (edit | diff) and testcases (edit | run) pages.
Add categories to the /doc subpage. Subpages of this module.
-- This module implements {{error}}. localp={} localfunction_error(args) localtag=mw.ustring.lower(tostring(args.tag)) -- Work out what html tag we should use. ifnot(tag=='p'ortag=='span'ortag=='div')then tag='strong' end -- Generate the html. returntostring(mw.html.create(tag) :addClass('error') :cssText(args.style) :wikitext(tostring(args.messageorargs[1]orerror('no message specified',2))) ) end functionp.error(frame) localargs iftype(frame.args)=='table'then -- We're being called via #invoke. The args are passed through to the module -- from the template page, so use the args that were passed into the template. args=frame.args else -- We're being called from another module or from the debug console, so assume -- the args are passed in directly. args=frame end -- if the message parameter is present but blank, change it to nil so that Lua will -- consider it false. ifargs.message==""then args.message=nil end return_error(args) end returnp