Module:Ustring: Difference between revisions

Content deleted Content added
Undid revision 886758119 by Ans (talk) The thing is, though, that Module:Ustring is the only module on all of Wikipedia that calls Module:LuaCall, so no "common code" argument can be made with p.import, which is in any case out of scope of the module
m Changed protection settings for "Module:Ustring": Used by fully protected Template:Str rightc -> Template:New page DYM -> Template:No article text (-> WP:CASC) ([Edit=Require administrator access] (indefinite))
 
(10 intermediate revisions by 6 users not shown)
Line 1:
require('strict')
local p = {}
return setmetatable({}, {
 
p[k]__index = function(framet, k)
for k, v in pairs(mw.ustring) do
local what = mw.ustring[k]
p[k] = function(frame)
if type(what) ~= "function" then
local args = frame.args
return pwhat
for _, v in ipairs(args) do
args[_] = tonumber(v) or v:gsub("^\\", "", 1)
end
return function(frame)
if args.tag then
local tagfargs = {name = argsframe.tag, content = mw.ustring[k](unpack(args)), args = {}}
local fargsused = { tag = true }
for x, y in pairs(args) do
local pargs = {}
if type(x)~='number' and x~='tag' then tag.args[x] = y end
local argsstr_i = frame.args1
while fargs['s' .. str_i] do
fargsused['s' .. str_i] = true
args[str_i] = fargs['s' .. str_i]
str_i = str_i + 1
end
for _i, v in ipairs(argsfargs) do
return frame:extensionTag(tag)
fargsused[i] = true
args[_i + str_i - 1] = tonumber(v) or v:gsub("^\\", "", 1)
end
if argsnot fargs.tag then
return (what(unpack(args))) -- Outside parens truncate to first result avoiding tail call
end
local tagargs = {}
for kx, vy in pairs(mw.ustringfargs) do
if not fargsused[x] then tagargs[x] = y end
end
return frame:extensionTag{name = fargs.tag, content = what(unpack(args)), args = tagargs}
end
return (mw.ustring[k](unpack(args)))
end
})
end
 
return p