Module:Template link general: Difference between revisions
m 1 revision imported: importing Template:Maintenance category |
En:Wp>Primefac fix the brace param issue |
||
| Line 32: | Line 32: | ||
end | end | ||
-- Builds the link part | |||
local function linkTitle(args) | local function linkTitle(args) | ||
local titleObj | local titleObj | ||
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 | ||
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 .. ']]' | 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('}') | ||
end | |||
local bold = _ne(args.bold) or _ne(args.boldlink) or _ne(args.boldname) | |||
if bold then | |||
titlePart = "'''" .. titlePart .. "'''" | |||
end | |||
if _ne(args.nowrapname) 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 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) | ||
local titlePart = linkTitle(args) | local titlePart = linkTitle(args) | ||
-- Build the arguments | -- Build the arguments | ||
| Line 152: | Line 150: | ||
if show_result then | if show_result then | ||
if _ne(args.nocat) then codeArguments['nocat'] = true end | |||
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 | ||