Jump to content

Module:Template link general and Module:Template link general/sandbox: Difference between pages

(Difference between pages)
Content deleted Content added
put subst on if nolink
 
 
Line 32: Line 32:
end
end


-- the link part
local function linkTitle(args)
local function linkTitle(args)
if _ne(args.nolink) then
if _ne(args.subst) then
return 'subst:' .. args['1']
else
return args['1']
end
end
local titleObj
local titleObj
local titlePart = '[['
if args['1'] then
if args['1'] then
-- This handles :Page and other NS
-- This handles :Page and other NS
Line 49: Line 41:
titleObj = mw.title.getCurrentTitle()
titleObj = mw.title.getCurrentTitle()
end
end

titlePart = titlePart .. (titleObj ~= nil and titleObj.fullText or
addTemplate(args['1']))
local textPart = args.alttext
local textPart = args.alttext
if not _ne(textPart) then
if not _ne(textPart) then
Line 73: Line 62:
textPart = nw('{') .. textPart .. nw('}')
textPart = nw('{') .. textPart .. nw('}')
end
end

titlePart = titlePart .. '|' .. textPart .. ']]'
titlePart
if _ne(args.nolink) then
titlePart =
else
titlePart = .. (titleObj ~= nil and titleObj.fullText or
'|' .. textPart .. ']]'
end
if _ne(args.braceinside) then
if _ne(args.braceinside) then
titlePart = nw('{') .. titlePart .. nw('}')
titlePart = nw('{') .. titlePart .. nw('}')
end
local bold = _ne(args.bold) or _ne(args.boldlink) or _ne(args.boldname)
if bold then
titlePart = "'''" .. titlePart .. "'''"
end
if _ne(args.) then
titlePart = '<span class="nowrap">' .. titlePart .. '</span>'
end
end
return titlePart
return titlePart
Line 90: Line 92:


function p._main(args)
function p._main(args)
local bold = _ne(args.bold) or _ne(args.boldlink) or _ne(args.boldname)
local italic = _ne(args.italic) or _ne(args.italics)
local italic = _ne(args.italic) or _ne(args.italics)
local dontBrace = _ne(args.brace) or _ne(args.braceinside)
local dontBrace = _ne(args.brace) or _ne(args.braceinside)
Line 97: Line 98:
local expand = _ne(args._expand)
local expand = _ne(args._expand)
-- Build the link part
local titlePart = linkTitle(args)
local titlePart = linkTitle(args)
if bold then titlePart = "'''" .. titlePart .. "'''" end
if _ne(args.nowrapname) then titlePart = '<span class="nowrap">' .. titlePart .. '</span>' end
-- Build the arguments
-- Build the arguments