Module:Ustring: Difference between revisions

Content deleted Content added
m heh, I was really lazy when I first made this; just simplifying
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))
 
(21 intermediate revisions by 7 users not shown)
Line 1:
require('strict')
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, esc = {}, string.char(127,4,127,2)
return pwhat
for _, v in ipairs(frame.args) do
table.insert(args, tonumber(v) or v:gsub("\\\\",esc):gsub("\\", ""):gsub(esc, "\\"))
end
ifreturn function(frame.args.tag then)
local tag = {namefargs = frame.args.tag, content = mw.ustring[k](unpack(args)), args = {}}
local fargsused = { tag = true }
for x, y in pairs(frame.args) do
local args = {}
if type(x)~='number' and x~='tag' and not tag[x] then tag.args[x] = y end
local str_i = 1
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(frame.argsfargs) do
return frame:extensionTag(tag)
fargsused[i] = true
args[i + str_i - 1] = tonumber(v) or v:gsub("^\\", "", 1)
end
if not 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