Module:Hatnote: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(sorry about that; we need to keep findNamespaceId around for other modules) |
(fix a mistake in the module comments; allow overriding the title in makeWikitextError; allow people to call _hatnote without an options table; and remove a comment about usage, as it is now covered in the test cases) |
||
Line 34: | Line 34: | ||
-- function will not work if the link is enclosed in double brackets. Colons |
-- function will not work if the link is enclosed in double brackets. Colons |
||
-- are trimmed from the start of the link by default. To skip colon |
-- are trimmed from the start of the link by default. To skip colon |
||
-- trimming, set the removeColon parameter to |
-- trimming, set the removeColon parameter to false. |
||
-- |
|||
-- This function is used by other modules, e.g. [[Module:Main]]. |
|||
checkType('findNamespaceId', 1, link, 'string') |
checkType('findNamespaceId', 1, link, 'string') |
||
checkType('findNamespaceId', 2, removeColon, 'boolean', true) |
checkType('findNamespaceId', 2, removeColon, 'boolean', true) |
||
Line 77: | Line 75: | ||
end |
end |
||
function p.makeWikitextError(msg, helpLink, addTrackingCategory) |
function p.makeWikitextError(msg, helpLink, addTrackingCategory, title) |
||
-- 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 85: | Line 83: | ||
checkType('makeWikitextError', 2, helpLink, 'string', true) |
checkType('makeWikitextError', 2, helpLink, 'string', true) |
||
yesno = require('Module:Yesno') |
yesno = require('Module:Yesno') |
||
title = title or mw.title.getCurrentTitle() |
|||
-- Make the help link text. |
-- Make the help link text. |
||
local helpText |
local helpText |
||
Line 192: | Line 190: | ||
checkType('_hatnote', 1, s, 'string') |
checkType('_hatnote', 1, s, 'string') |
||
checkType('_hatnote', 2, options, 'table', true) |
checkType('_hatnote', 2, options, 'table', true) |
||
options = options or {} |
|||
local classes = {'hatnote'} |
local classes = {'hatnote'} |
||
local extraclasses = options.extraclasses |
local extraclasses = options.extraclasses |