Open main menu

Changes

Module:Hatnote

129 bytes removed, 15:51, 29 April 2014
merge rellink into hatnote, use an options table to pass options to the hatnote function, and add a tracking category for errors
-- Formats an error message to be returned to wikitext.
checkType('_makeWikitextError', 1, msg, 'string')
local errorCategory = 'Hatnote templates with errors' local errorCategoryLink = errorCategory and string.format( '[[%s:%s]]', mw.site.namespaces[14].name, errorCategory ) or '' return string.format( '<strong class="error">Error: %s.</strong>%s', msg, errorCategoryLink )
end
local args = getArgs(frame)
local s = args[1]
local options = {}
if not s then
return p._makeWikitextError('no text specified')
end
options.extraclasses = args.extraclasses options.selfref = args.selfref return p._hatnote(s, options)
end
function p._hatnote(s, options)
checkType('_hatnote', 1, s, 'string')
return string.formatcheckType('<div class="dablink">%s</div>_hatnote', 2, options, 'table', strue)end ---------------------------------------------------------------------------------- Rellink---- Produces a standard link to a related article. Implements the { local classes = {'rellink'}}-- template.-------------------------------------------------------------------------------- function p.rellink(frame) local args extraclasses = getArgs(frame)options.extraclasses local s selfref = args[1]options.selfref local if type(extraclasses ) == args.extraclasses if not s 'string' then return p._makeWikitextError('no text specified')classes[#classes + 1] = extraclasses
end
return p._rellink(s, extraclasses)end function p._rellink(s, extraclasses) checkType('_rellink', 1, s, 'string') checkType('_rellink', 2, extraclasses, 'string', true) if extraclasses selfref then extraclasses = ' ' .. extraclasses else extraclasses classes[#classes + 1] = 'selfref'
end
return string.format( '<div class="rellink%s">%s</div>', extraclasses table.concat(classes, ' '), s )
end
return p
Anonymous user