Module:Parameters/sandbox: Difference between revisions

Content deleted Content added
m sync with live version
test
 
(6 intermediate revisions by the same user not shown)
Line 68:
 
function p._check(args)
local title = args._basebase or mw.title.getCurrentTitle().fullText
return string.format(
'{{#invoke:Check for unknown parameters|check|unknown=' ..
Line 91:
end
 
local title = args._basebase or mw.title.getCurrentTitle().baseText
return string.format([[ <nowiki>{{%s
%s}}</nowiki>]], title, strMap(parameters,
function(s)
if definitions then
Line 102:
end
end))
end
 
function p._flatcode(args)
local parameters = extractParams(args.base)
local title = args.base or mw.title.getCurrentTitle().baseText
return string.format(' {{tlp|%s%s}}', title, strMap(parameters,
function(s)
return string.format(' |%s{{=}}<var>%s</var> ', s, s)
end)
)
end
 
Line 161 ⟶ 171:
 
function p._demo(args)
local title = args._basebase and ('|_template=' .. args._basebase) or ''
return string.format('{{Parameter names example%s|%s}}', title,
table.concat(extractParams(args.base), '|'))
Line 168 ⟶ 178:
function p._dlist(args)
local definitions = yesno(args.definitions, true)
local defFormat = '; %s: %s\n'
local nonDefFormat = '; %s: \n'
if args._para then
defFormat = '; {{para|%s}}: %s\n'
nonDefFormat = '; {{para|%s}}: \n'
end
return strMap(extractParams(args.base),
function(s)
if definitions then
return string.format('; %s: %s\n'defFormat, s,
DEFINITIONS[s] and DEFINITIONS[s].dlist or '')
else
return string.format('; %s: \n'nonDefFormat, s)
end
end)
end
 
function p._dlistpara(args)
args._para = true
return p._dlist(args)
end
 
Line 183 ⟶ 204:
function(s) return string.format('* %s\n', s) end)
end
 
 
p.check = makeInvokeFunction('_check')
p.code = makeInvokeFunction('_code')
p.flatcode = makeInvokeFunction('_flatcode')
p.compare = makeInvokeFunction('_compare')
p.demo = makeInvokeFunction('_demo')
p.dlist = makeInvokeFunction('_dlist')
p.dlistpara = makeInvokeFunction('_dlistpara')
p.list = makeInvokeFunction('_list')