From Wikipedia, the free encyclopedia
👁 Image
| 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
-- This module implements {{error}}.
localp={}
functionp._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
returnp._error(args)
end
returnp