Modul:Hatnote: Unterschied zwischen den Versionen
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
(don't categorise talk namespaces) |
(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) |
||
Zeile 11: | Zeile 11: | ||
local mArguments -- lazily initialise [[Module:Arguments]] | local mArguments -- lazily initialise [[Module:Arguments]] | ||
local yesno -- lazily initialise [[Module:Yesno]] | local yesno -- lazily initialise [[Module:Yesno]] | ||
local p = {} | local p = {} | ||
Zeile 76: | Zeile 75: | ||
end | end | ||
function p.makeWikitextError(msg, | function p.makeWikitextError(msg, 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 | ||
-- [[Module:Yesno]], and if we are not on a talk page, a tracking category | |||
-- is added. | |||
checkType('makeWikitextError', 1, msg, 'string') | checkType('makeWikitextError', 1, msg, 'string') | ||
yesno = require('Module:Yesno') | yesno = require('Module:Yesno') | ||
local title = mw.title.getCurrentTitle() | |||
local | local category | ||
if not title.isTalkPage and yesno(addTrackingCategory) ~= false then | |||
category = 'Hatnote templates with errors' | |||
category = string.format( | |||
'[[%s:%s]]', | |||
mw.site.namespaces[14].name, | |||
category | |||
) | |||
else | |||
category = '' | |||
end | |||
return string.format( | return string.format( | ||
'<strong class="error">Error: %s.</strong>%s', | '<strong class="error">Error: %s.</strong>%s', | ||
msg, | msg, | ||
category | |||
) | ) | ||
end | end |