Module:Error: Difference between revisions
Jump to navigation
Jump to search
(Created page with "------------------------------------------------------------------------------- -- -- Module:Error -- -- This module implements Template:Error...") |
>Vinifera7 No edit summary |
||
Line 14: | Line 14: | ||
} | } | ||
cfg.tag = ' | cfg.tag = 'strong' | ||
-- ---------------------------------------------------------------------------- | -- ---------------------------------------------------------------------------- |
Revision as of 18:50, 4 June 2021
You might want to create a documentation page for this module.
Editors can experiment in this module's sandbox and testcases pages.
Please add categories to the /doc subpage. Subpages of this module.
Editors can experiment in this module's sandbox and testcases pages.
Please add categories to the /doc subpage. Subpages of this module.
-------------------------------------------------------------------------------
--
-- Module:Error
--
-- This module implements Template:Error
-------------------------------------------------------------------------------
local cfg = {}
cfg.i18n = {}
cfg.i18n.errors = {
no_message = 'No message specified.',
}
cfg.tag = 'strong'
-- ----------------------------------------------------------------------------
-- Main function
-- ----------------------------------------------------------------------------
local function _main(args)
args.message = args.message or args[1]
if not args.message or args.message == '' then
error(cfg.i18n.errors.no_message, 2)
end
local html = mw.html.create(cfg.tag)
:addClass('error')
:wikitext(tostring(args.message))
return tostring(html)
end
-- ----------------------------------------------------------------------------
-- Exported functions
-- ----------------------------------------------------------------------------
local p = {}
function p.main(frame)
local args
if type(frame.args) == 'table' then
-- Called via #invoke, so use the args that were passed into the
-- template.
args = frame.args
else
-- Called from another module or from the debug console, so assume args
-- are passed in directly.
args = frame
end
return _main(args)
end
p.error = p.main
return p