Module:Hatnote: Difference between revisions

249 bytes added ,  10 years ago
add helpLink parameter to makeWikitextError
m>Mr. Stradivarius
(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)
m>Mr. Stradivarius
(add helpLink parameter to makeWikitextError)
Line 75: Line 75:
end
end


function p.makeWikitextError(msg, addTrackingCategory)
function p.makeWikitextError(msg, helpLink, addTrackingCategory)
-- Formats an error message to be returned to wikitext. If
-- Formats an error message to be returned to wikitext. If
-- addTrackingCategory is not false after being returned from
-- addTrackingCategory is not false after being returned from
Line 81: Line 81:
-- is added.
-- is added.
checkType('makeWikitextError', 1, msg, 'string')
checkType('makeWikitextError', 1, msg, 'string')
checkType('makeWikitextError', 2, helpLink, 'string', true)
yesno = require('Module:Yesno')
yesno = require('Module:Yesno')
local title = mw.title.getCurrentTitle()
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
local category
if not title.isTalkPage and yesno(addTrackingCategory) ~= false then
if not title.isTalkPage and yesno(addTrackingCategory) ~= false then
Line 95: Line 104:
end
end
return string.format(
return string.format(
'<strong class="error">Error: %s.</strong>%s',
'<strong class="error">Error: %s%s.</strong>%s',
msg,
msg,
helpText,
category
category
)
)
Anonymous user