Module:Hatnote inline: Difference between revisions

changing to inline version with span
m>SMcCandlish
(starting with fresh copy of code from Module:Hatnote)
m>SMcCandlish
(changing to inline version with span)
Line 1: Line 1:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--                             Module:Hatnote                               --
--                         Module:Hatnote-inline                            --
--                                                                            --
--                                                                            --
-- This module produces hatnote links and links to related articles. It       --
-- This module produces inline hatnote (i.e. cross-reference) notes and links --
-- implements the {{hatnote}} and {{format hatnote link}} meta-templates, and --
-- to related articles. It implements the {{hatnote-inline}} meta-templates, --
-- includes helper functions for other Lua hatnote modules.                  --
-- and includes helper functions for other Lua hatnote modules (for now)      --
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


Line 166: Line 166:


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Hatnote
-- HatnoteInline
--
--
-- Produces standard hatnote text. Implements the {{hatnote}} template.
-- Produces standard inline hatnote text.
-- Implements the {{hatnote-inline}} template.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


function p.hatnote(frame)
function p.hatnoteInline(frame)
local args = getArgs(frame)
local args = getArgs(frame)
local s = args[1]
local s = args[1]
Line 178: Line 179:
return p.makeWikitextError(
return p.makeWikitextError(
'no text specified',
'no text specified',
'Template:Hatnote#Errors',
'Template:Hatnote-inline#Errors',
args.category
args.category
)
)
Line 184: Line 185:
options.extraclasses = args.extraclasses
options.extraclasses = args.extraclasses
options.selfref = args.selfref
options.selfref = args.selfref
return p._hatnote(s, options)
return p._hatnoteInline(s, options)
end
end


function p._hatnote(s, options)
function p._hatnoteInline(s, options)
checkType('_hatnote', 1, s, 'string')
checkType('_hatnoteInline', 1, s, 'string')
checkType('_hatnote', 2, options, 'table', true)
checkType('_hatnoteInline', 2, options, 'table', true)
local classes = {'hatnote'}
local classes = {'hatnote-inline'}
local extraclasses = options.extraclasses
local extraclasses = options.extraclasses
local selfref = options.selfref
local selfref = options.selfref
Line 200: Line 201:
end
end
return string.format(
return string.format(
'<div class="%s">%s</div>',
'<span class="%s">%s</span>',
table.concat(classes, ' '),
table.concat(classes, ' '),
s
s
Anonymous user