Difference between revisions of "Module:Sandbox/BrandonXLF/1"
< Module:Sandbox | BrandonXLF
Jump to navigation
Jump to search
blackwiki>BrandonXLF (Restored revision 883984777 by BrandonXLF (Restorer)) |
m (554 revisions imported) |
||
| (8 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
| − | + | ---------- DO NOT DELETE ---------- | |
| − | function | + | |
| − | local | + | function main (frame, switch) |
| − | local | + | local fArgs = frame.args |
| − | local | + | local pArgs = frame:getParent().args |
| − | local template | + | local tArgs = {} |
| − | + | local template = fArgs['_'] | |
if not template then | if not template then | ||
| − | return require('Module:Error').error | + | return require('Module:Error').error{'Error: No template name given.'} |
end | end | ||
| − | if | + | fArgs._ = nil |
| − | + | if switch then | |
| + | pArgs, fArgs = fArgs, pArgs | ||
end | end | ||
| − | for k,v in pairs( | + | for k, v in pairs(fArgs) do |
| − | + | tArgs[k] = v | |
end | end | ||
| − | for k,v in pairs( | + | for k, v in pairs(pArgs) do |
| − | + | tArgs[k] = v | |
end | end | ||
| − | return frame:expandTemplate{title = template, args = | + | return frame:expandTemplate{title = template, args = tArgs} |
end | end | ||
| − | return | + | |
| + | return { | ||
| + | default = function (frame) return main(frame) end, | ||
| + | force = function (frame) return main(frame, true) end | ||
| + | } | ||
Latest revision as of 09:27, 27 September 2020
DO NOT DELETE
Module:Call calls a template while giving it all the arguments the current page receives. It is meant to be used in the template namespace and will only work in other namespaces if the page it's being used on is transcluded on another page.
Usage
There are two ways of using the module, using the default function and using the force function.
Set default values for parameters
{{#invoke:call|default|_=template}}
When using the default function, parameters supplied to the #invoke call will be overridden by parameters sent to the template calling this module.
Set forced values for parameters
{{#invoke:call|force|_=template}}
When using the force function, parameters supplied to the #invoke call will override parameters sent to the template calling this module.
---------- DO NOT DELETE ----------
function main (frame, switch)
local fArgs = frame.args
local pArgs = frame:getParent().args
local tArgs = {}
local template = fArgs['_']
if not template then
return require('Module:Error').error{'Error: No template name given.'}
end
fArgs._ = nil
if switch then
pArgs, fArgs = fArgs, pArgs
end
for k, v in pairs(fArgs) do
tArgs[k] = v
end
for k, v in pairs(pArgs) do
tArgs[k] = v
end
return frame:expandTemplate{title = template, args = tArgs}
end
return {
default = function (frame) return main(frame) end,
force = function (frame) return main(frame, true) end
}