Editing Module:AddcommasGive feedback
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision | Your text | ||
| Line 10: | Line 10: | ||
-- | -- | ||
function p._add(arg, sep) | function p._add(arg, sep) | ||
-- If called internally (direct Lua call), args will be passed directly. | |||
-- If called from wikitext, `arg` will be the `frame` object, and we get args from `frame.args`. | |||
-- Handle the case where it's called via #invoke (i.e., from wikitext) | |||
if type(arg) == "table" and arg.args then | |||
local frame = arg | |||
arg = frame.args[1] | |||
sep = frame.args[2] | |||
end | |||
libraryUtil.checkTypeMulti('Module:Addcommas._add', 1, arg, {'number', 'string'}) | libraryUtil.checkTypeMulti('Module:Addcommas._add', 1, arg, {'number', 'string'}) | ||
libraryUtil.checkType('"Module:Addcommas"._add', 2, sep, "string", true); | libraryUtil.checkType('"Module:Addcommas"._add', 2, sep, "string", true); | ||
| Line 47: | Line 57: | ||
function p._strip(str) | function p._strip(str) | ||
libraryUtil.checkType('Module:Addcommas._strip', 1, str, 'string') | libraryUtil.checkType('Module:Addcommas._strip', 1, str, 'string') | ||
return str:gsub(',', '') | |||
end | end | ||
--[=[ | |||
function p.commas(frame) | function p.commas(frame) | ||
local args = require("Module:Arguments").getArgs(frame); | |||
return p._add(args[1], args.sep); | |||
end | end | ||
--]=] | |||
return p | return p | ||