Difference between revisions of "Module:For"
Jump to navigation
Jump to search
Rixithechao (talk | contribs) (Created page with "local export = {} function export.render(frame) local for_args = frame:getParent().args local tname = for_args.call or "1x" local sep = for_args[1] local pv = for_args.p...") |
Rixithechao (talk | contribs) |
||
Line 7: | Line 7: | ||
local sep = for_args[1] | local sep = for_args[1] | ||
local pv = for_args.pv or "1" | local pv = for_args.pv or "1" | ||
local inam = for_args.i or "i" | |||
local prefix = for_args.prefix or "" | local prefix = for_args.prefix or "" | ||
local suffix = for_args.suffix or "" | local suffix = for_args.suffix or "" | ||
Line 25: | Line 26: | ||
local args = mw.clone(pc) | local args = mw.clone(pc) | ||
args[pv] = prefix .. for_args[i] .. suffix | args[pv] = prefix .. for_args[i] .. suffix | ||
args[inam] = i-1 | |||
if output[1] then | if output[1] then |
Latest revision as of 06:06, 8 June 2021
Documentation for this module may be created at Module:For/doc
local export = {} function export.render(frame) local for_args = frame:getParent().args local tname = for_args.call or "1x" local sep = for_args[1] local pv = for_args.pv or "1" local inam = for_args.i or "i" local prefix = for_args.prefix or "" local suffix = for_args.suffix or "" local pc = {} local output = {} local i = 1 while for_args["pc" .. i .. "n"] do local pnam = for_args["pc" .. i .. "n"] local pval = for_args["pc" .. i .. "v"] pc[pnam] = pval i = i + 1 end i = 2 while for_args[i] do local args = mw.clone(pc) args[pv] = prefix .. for_args[i] .. suffix args[inam] = i-1 if output[1] then output[#output + 1] = sep end output[#output + 1] = frame:expandTemplate { title = tname, args = args } i = i + 1 end return table.concat(output) end return export