Module:Ustring: Difference between revisions

Content deleted Content added
m Changed protection level for "Module:Ustring": High-risk Lua module: per request at WP:RFPP; used by TE protected Template:R from Unicode character ([Edit=Require template editor access] (indefinite))
Make it possible to pass strings like '0005' to new arguments s1, s2, ... without having leading zeroes stripped
Line 1:
require('Module:No globals')
return setmetatable({}, {
__index = function(t, k)
Line 7 ⟶ 6:
end
return function(frame)
local args = frame.args{}
local str_i = 1
for _, v in ipairs(args) do
while frame.args['s' .. str_i] do
args[_] = tonumber(v) or v:gsub("^\\", "", 1)
args[str_i] = frame.args['s' .. str_i]
str_i = str_i + 1
end
for _i, v in ipairs(frame.args) do
if not args.tag then
args[_i + str_i - 1] = tonumber(v) or v:gsub("^\\", "", 1)
return (what(unpack(args)))
end
if not frame.args.tag then
return (what(unpack(args)))
end
local tagargs = {}
for x, y in pairs(frame.args) do
if type(x) ~= 'number' and x ~= 'tag' then tagargs[x] = y end
end
return frame:extensionTag{name = frame.args.tag, content = what(unpack(args)), args = tagargs}
end
end