This is the documentation page for Module:ArgsUtil
Module:ArgsUtil is a tiny helper that other modules use to collect a template's arguments, merged with any defaults set directly in the Script error: You must specify a function to call. call.
Overview
This is a building-block module, not something used on pages. When a template like Template:Foo calls Script error: No such module "Foo"., a Lua module often wants both sets of arguments combined: the defaults written in the invoke (b=2) plus whatever the editor passed to the template (a=1), with the editor's values winning. Module:ArgsUtil does exactly that in one function.
It has a single exported function, merge, and no configuration. It is required by other modules (for example {{Template link}}m) rather than invoked from a page.
Functions / entry points
| Function (#invoke) | What it does | Called by |
|---|---|---|
p.merge |
Returns a single args table: it reads the current frame's own args (the invoke) and the parent frame's args (the template), trims them, drops empty values, and merges them so the parent (template) args override the invoke args. Takes no parameters — it fetches the current frame itself. | Other Lua modules via require, e.g. {{Template link}}m
|
How it's used
This is called from Lua, not from wikitext. Typical pattern:
local util_args = require('Module:ArgsUtil')
local p = {}
function p.main(frame)
local args = util_args.merge() -- no need to pass `frame`; merge() finds it
-- `args` = invoke defaults overridden by whatever the template was given
end
return pFor example, {{Template link}}m begins with local getArgs = require('Module:ArgsUtil').merge and calls getArgs() in its p.main.
Ordinary editors never touch this module.
Notes
- Precedence: template (parent) values win over invoke values. (This is the opposite of
{{Infobox}}m's internalh.overwritehelper, which deliberately lets the invoke override the template — keep that distinction in mind if you compare the two.) - Empty strings are discarded during the merge, so a blank parameter does not clobber a default.
- By design it ships with only this one function and no options, to keep it simple. The pre-existing wiki doc notes an extended version is available on the support wiki if more functionality is needed.
- Related:
{{Template link}}m(its main consumer).