Module:For loop/sandbox: Difference between revisions

Content deleted Content added
require Module:Template invocation only if required (see Template talk:Post-nominals#Use of Module:Template_invocation); clean whitespace, variables
test
Line 10:
removeBlanks = false
})
return p._main(args, false)
end
 
function p._maintemplatemain(argsframe)
local args = getArgs(frame, {
trim = false,
removeBlanks = false
})
return p._main(args, true)
end
 
function p._main(args, usechild)
local template = args['call'] or 'void'
local calltemplates = yesno(args.substall or "", true) or not mw.isSubsting()
Line 36 ⟶ 44:
targs[variableParam] = variableValPrefix .. v .. variableValPostfix
if calltemplates then
local output = p.callTemplate(template, targs, usechild)
if #mw.text.trim(output) == 0 then
addSeparator = false
Line 101 ⟶ 109:
end
 
function p.callTemplate(template, targs, usechild)
returnframe = mw.getCurrentFrame():expandTemplate{title = template, args = targs}
if usechild then
frame = frame:newChild{title = "Template:For_loop", args = targs}
end
return frame:expandTemplate{title = template, args = targs}
end