Module:Hatnote: Difference between revisions

add helpLink parameter to makeWikitextError
(update the makeWikitextError function - don't use Module:Category handler, and use an addTrackingCategory parameter instead of a demo parameter, to make it easy for daughter modules to add a category=no parameter)
(add helpLink parameter to makeWikitextError)
Line 75:
end
 
function p.makeWikitextError(msg, helpLink, addTrackingCategory)
-- Formats an error message to be returned to wikitext. If
-- addTrackingCategory is not false after being returned from
Line 81:
-- is added.
checkType('makeWikitextError', 1, msg, 'string')
checkType('makeWikitextError', 2, helpLink, 'string', true)
yesno = require('Module:Yesno')
local title = mw.title.getCurrentTitle()
-- Make the help link text.
local helpText
if helpLink then
helpText = ' ([[' .. helpLink .. '|help]])'
else
helpText = ''
end
-- Make the category text.
local category
if not title.isTalkPage and yesno(addTrackingCategory) ~= false then
Line 95 ⟶ 104:
end
return string.format(
'<strong class="error">Error: %s%s.</strong>%s',
msg,
helpText,
category
)
Anonymous user