This module is used to call another template (Callee) in one template (Caller). Due to technical limitations, please use {{#invoke:Call}} to invoke this module directly in Caller.
{{#invoke:Call|main|template name[|other parameters]}}
Due to the limitations of Lua itself, the order in which named arguments are passed in is not deterministic, so the results of using the {{#forargs:}} parser function may not be as expected.
local p = {}
local getArgs = require('Module:Arguments').getArgs
function p._main(frame, args, is_default_value)
local calleeName = args[1]
if (not calleeName) or (calleeName == "") then
return ""
end
local wrapperArgs = getArgs(frame, { parentOnly = true })
for k, v in pairs(args) do
local k_number = tonumber(k)
if k_number then
if k_number > 1 then
if not (wrapperArgs[k_number - 1] and is_default_value) then
wrapperArgs[k_number - 1] = v
end
end
else
if not (wrapperArgs[k] and is_default_value) then
wrapperArgs[k] = v
end
end
end
-- mw.logObject(wrapperArgs)
return frame:expandTemplate({ title = calleeName, args = wrapperArgs })
end
function p.main(frame)
return p._main(frame, getArgs(frame, { frameOnly = true }), false)
end
function p.default(frame)
return p._main(frame, getArgs(frame, { frameOnly = true }), true)
end
return p