Modul:Format link: Unterschied zwischen den Versionen

Further copied getArgs from Module:Hatnote and organized into helper and main functions
(Presumably doesn't work yet, but … basic code copied from Module:Hatnote, which includes contributions from Mr. Stradivarius, SMcCandlish, Codename Lisa, Ahecht, Qed237, Nihiltres, JJMC89, Pppery, and Izno.)
 
(Further copied getArgs from Module:Hatnote and organized into helper and main functions)
Zeile 13: Zeile 13:
local yesno -- lazily initialise [[Module:Yesno]]
local yesno -- lazily initialise [[Module:Yesno]]


function p.formatLink(frame)
local p = {}
-- The formatLink export function, for use in templates.
 
yesno = require('Module:Yesno')
--------------------------------------------------------------------------------
local args = getArgs(frame)
-- Helper functions
local link = args[1]
--------------------------------------------------------------------------------
if not link then
 
return p.makeWikitextError(
local function getArgs(frame)
'no link specified',
-- Fetches the arguments from the parent frame. Whitespace is trimmed and
'Template:Format link#Errors',
-- blanks are removed.
args.category
mArguments = require('Module:Arguments')
)
return mArguments.getArgs(frame, {parentOnly = true})
end
return p._formatLink{
link = link,
display = args[2],
italicizePage = yesno(args.italicizepage),
italicizeSection = yesno(args.italicizesection),
}
end
end


Zeile 84: Zeile 77:
section = section,
section = section,
display = display,
display = display,
}
end
--------------------------------------------------------------------------------
-- Main functions
--------------------------------------------------------------------------------
function p.formatLink(frame)
-- The formatLink export function, for use in templates.
yesno = require('Module:Yesno')
local args = getArgs(frame)
local link = args[1]
if not link then
return p.makeWikitextError(
'no link specified',
'Template:Format link#Errors',
args.category
)
end
return p._formatLink{
link = link,
display = args[2],
italicizePage = yesno(args.italicizepage),
italicizeSection = yesno(args.italicizesection),
}
}
end
end
Anonymer Benutzer