1,535
edits
(create a replacement for Template:Parameter names example) |
m (11 revisions imported from templatewiki:Module:Parameter_names_example) |
||
(10 intermediate revisions by 6 users not shown) | |||
Line 11:
local function italicize(s)
return "''" .. s .. "''"
end
local function plain(s)
return s
end
Line 16 ⟶ 20:
-- Find how we want to format the arguments to the template.
local formatFunc
if args.
formatFunc = italicize
elseif args._display == 'plain' then
formatFunc = plain
else
formatFunc = makeParam
Line 24 ⟶ 30:
-- Build the table of template arguments.
local targs = {}
for
if type(k) == 'number' then
targs[
elseif not k:find('^_') then
targs[k] = v
end
end
-- Find the template name
local template
local template = args.template or mw.title.getCurrentTitle().basePageTitle.text▼
if args._template then
template = args._template
else
if currentTitle.prefixedText:find('/sandbox$') then
template = currentTitle.prefixedText
else
template = currentTitle.basePageTitle.prefixedText
end
end
-- Call the template with the arguments.
frame = frame or mw.getCurrentFrame()
local success, result = pcall(
return frame:expandTemplate{title = template, args = targs}▼
frame.expandTemplate,
frame,
)
if success then
return result
else
return ''
end
end
|