Jump to content

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

(Difference between pages)
Page 1
Page 2
Content deleted Content added
put subst on if nolink
 
linkTitle: try to simplify logic
 
Line 33: Line 33:


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 40:
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 61:
textPart = nw('{') .. textPart .. nw('}')
textPart = nw('{') .. textPart .. nw('}')
end
end

titlePart = titlePart .. '|' .. textPart .. ']]'
local titlePart
if _ne(args.nolink) then
titlePart = textPart
else
titlePart = '[[' .. (titleObj ~= nil and titleObj.fullText or addTemplate(args['1'])) ..
'|' .. textPart .. ']]'
end
if _ne(args.braceinside) then
if _ne(args.braceinside) then
titlePart = nw('{') .. titlePart .. nw('}')
titlePart = nw('{') .. titlePart .. nw('}')
Line 152: Line 146:


if show_result then
if show_result then
codeArguments['nocat'] = true
local result = mw.getCurrentFrame():expandTemplate{title = addTemplate(args[1]), args = codeArguments}
local result = mw.getCurrentFrame():expandTemplate{title = addTemplate(args[1]), args = codeArguments}
ret = ret .. " → " .. result
ret = ret .. " → " .. result