Anonymous user
Module:Hatnote: Difference between revisions
merge rellink into hatnote, use an options table to pass options to the hatnote function, and add a tracking category for errors
(checkType will work in for loops as well, with the power of the i variable) |
(merge rellink into hatnote, use an options table to pass options to the hatnote function, and add a tracking category for errors) |
||
Line 77:
-- Formats an error message to be returned to wikitext.
checkType('_makeWikitextError', 1, msg, 'string')
local errorCategory = 'Hatnote templates with errors'
return string.format('<strong class="error">Error: %s.</strong>', msg)▼
local errorCategoryLink = errorCategory
and string.format(
'[[%s:%s]]',
mw.site.namespaces[14].name,
errorCategory
)
or ''
return string.format(
msg,
errorCategoryLink
)
end
Line 138 ⟶ 150:
local args = getArgs(frame)
local s = args[1]
if not s then
return p._makeWikitextError('no text specified')
end
return p._hatnote(s)▼
options.selfref = args.selfref
▲ return p._hatnote(s, options)
end
function p._hatnote(s, options)
checkType('_hatnote', 1, s, 'string')
return string.format('<div class="dablink">%s</div>', s)▼
local classes = {'rellink'}
local selfref = options.selfref
if type(extraclasses) == 'string' then▼
classes[#classes + 1] = extraclasses
▲ local s = args[1]
▲ local extraclasses = args.extraclasses
if not s then▼
end
classes[#classes + 1] = 'selfref'
▲ checkType('_rellink', 2, extraclasses, 'string', true)
▲ if extraclasses then
▲ extraclasses = ' ' .. extraclasses
end
return string.format(
table.concat(classes, ' '),
s
)
end
|