Module:Utils: Difference between revisions
Jump to navigation
Jump to search
Created page with "local _m = {} _m.def = function(a, b) return (a ~= nil and a ~= "") and a or b end _m._a = function (x) if type(x) ~= "table" then return x end if x.args then return x.args[1] end return x[1] end return _m" |
mNo edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
end | end | ||
_m._a = function (x) | _m._a = function (x) | ||
if type(x) ~= "table" then return x end | if type(x) ~= "table" then | ||
if x.args then return x.args[1] end | return x | ||
end | |||
-- Did we get a frame | |||
if type(x.args) == "table" then return x.args[1] end | |||
-- Also support passing the argument in a table | |||
return x[1] | return x[1] | ||
end | end | ||
return _m | return _m |
Latest revision as of 09:21, 15 April 2025
Documentation for this module may be created at Module:Utils/doc
local _m = {}
_m.def = function(a, b)
return (a ~= nil and a ~= "") and a or b
end
_m._a = function (x)
if type(x) ~= "table" then
return x
end
-- Did we get a frame
if type(x.args) == "table" then return x.args[1] end
-- Also support passing the argument in a table
return x[1]
end
return _m