Module:Call
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.
Usage
{{#invoke:Call|main|template name[|other parameters]}}
- input
-
- 1: Template (Callee) name.
- Other parameters: You can specify parameters in the template (Caller) when calling another template (Callee). If another page (Page) calls this template (Caller) with a parameter of the same name specified, the parameter value specified in the page (Page) will not take effect, that is, the parameter in the template (Caller) source code has a higher priority.
- output
- The result of calling Callee, whose parameters are specified by the source code of Caller and the page calling Caller.
Limitations
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