Module:Error: Difference between revisions

simplify code some more and trim whitespace from the message
(simplify argument-grabbing code)
(simplify code some more and trim whitespace from the message)
Line 6:
 
local function _error(args)
local smessage = args.message or args[1] or error('no message specified', 2)
message = mw.ustring.match(tostring(message), '^%s*(.*%S)') or '' -- Convert message to string and trim whitespace.
local tag = mw.ustring.lower(tostring(args.tag))
 
-- Work out what html tag we should use.
if not (tag == 'p' or tag == 'span' or tag == 'div') then
local t
if tag == 'p' or tag == 'spanstrong' or tag == 'div' then
t = tag
else
t = 'strong'
end
local root = HtmlBuilder.create(t)
 
-- Generate the html.
local root = HtmlBuilder.create(ttag)
root
.addClass('error')
.wikitext(tostring(s)message)
 
return tostring(root)
Line 48 ⟶ 46:
end
 
local args = origArgs
return _error(args)
end
Anonymous user