Anonymous user
Module:Format link: Difference between revisions
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) |
||
Line 13:
local yesno -- lazily initialise [[Module:Yesno]]
function p.formatLink(frame)▼
-- The formatLink export function, for use in templates.▼
--------------------------------------------------------------------------------
yesno = require('Module:Yesno')▼
-- Helper functions
local args = getArgs(frame)▼
--------------------------------------------------------------------------------
▲ local link = args[1]
if not link then▼
local function getArgs(frame)
return p.makeWikitextError(▼
-- Fetches the arguments from the parent frame. Whitespace is trimmed and
'no link specified',▼
-- blanks are removed.
'Template:Format link#Errors',▼
mArguments = require('Module:Arguments')
args.category▼
return mArguments.getArgs(frame, {parentOnly = true})
)▼
end▼
return p._formatLink{▼
link = link,▼
display = args[2],▼
italicizePage = yesno(args.italicizepage),▼
italicizeSection = yesno(args.italicizesection),▼
}▼
end
Line 84 ⟶ 77:
section = section,
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
|