Module:Ustring/sandbox: Difference between revisions

Content deleted Content added
remove new 's<n>' args from "tagargs"
use require('strict') instead of require('Module:No globals')
 
(2 intermediate revisions by one other user not shown)
Line 1:
require('Module:No globalsstrict')
return setmetatable({}, {
__index = function(t, k)
Line 8:
return function(frame)
local fargs = frame.args
local fargsused = { tag = true, onerror = true }
local args = {}
local str_i = 1
Line 19:
fargsused[i] = true
args[i + str_i - 1] = tonumber(v) or v:gsub("^\\", "", 1)
end
local result = nil
if fargs.onerror then
local success
success, result = pcall(what, unpack(args))
if not success then
return fargs.onerror
end
else
result = what(unpack(args))
end
if not fargs.tag then
return result
return (what(unpack(args))) -- Outside parens truncate to first result avoiding tail call
end
local tagargs = {}
Line 27 ⟶ 37:
if not fargsused[x] then tagargs[x] = y end
end
return frame:extensionTag{name = fargs.tag, content = what(unpack(args))result, args = tagargs}
end
end