2023年政策修订增补工作正在进行中,欢迎参与!
Module:ArrayTemplate
跳转到导航
跳转到搜索
-- Module:ArrayTemplate
-- Made with ♥ by User:Leranjun
-- This module implements {{tl|ApplyToArray}}.
-- Please refrain from invoking this module directly.
local p = {}
local getArgs = require("Module:Arguments").getArgs
function p.main(frame)
local args = getArgs(frame)
local tname, arr = args[1], args[2]
local cnt = frame:expandTemplate {title = "array", args = {"get", arr, "count"}}
local targs = {}
for i = 1, cnt, 2 do
local k = frame:expandTemplate {title = "array", args = {"get", arr, i}}
local v = frame:expandTemplate {title = "array", args = {"get", arr, i + 1}}
targs[k] = v
end
return frame:expandTemplate {title = tname, args = targs}
end
return p