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]] | ||
local p = {} | |||
-------------------------------------------------------------------------------- | |||
-- Helper functions | |||
-------------------------------------------------------------------------------- | |||
local function getArgs(frame) | |||
-- Fetches the arguments from the parent frame. Whitespace is trimmed and | |||
-- blanks are removed. | |||
mArguments = require('Module:Arguments') | |||
return mArguments.getArgs(frame, {parentOnly = true}) | |||
return | |||
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 | ||