Module:call
Appearance
- The following documentation is located at Module:call/documentation. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module is for making one template pass all of its arguments to another template. This can be used, for example, to conditionally redirect one template to another. In the future, more sophisticated argument passing will be implemented. For now, the simplest use is as follows:
{{#invoke:call|call|template}}
where template
is the template you want to redirect to. For example, deprecated template {{cola}}
can redirect all its arguments (which may be arbitrarily many) to {{col}}
using:
{{#invoke:call|call|col}}
Unfortunately, due to the nature of templates, there is no way to wrap this module invocation in a {{call}}
template or similar; the redirecting template must directly invoke the module.
local export = {}
function export.call(frame)
local frame_args = frame.args
local parent_args = frame:getParent().args
local args = {}
local template = frame_args[1]
for k, v in pairs(parent_args) do
args[k] = v
end
for k, v in pairs(frame_args) do
if k == 1 then
elseif type(k) == "number" then
args[k - 1] = v
else
args[k] = v
end
end
return frame:expandTemplate{title = template, args = args}
end
return export
-- For Vim, so we get 4-space tabs
-- vim: set ts=4 sw=4 noet: