Module:Ustring: Difference between revisions

Content deleted Content added
maintain error messages
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))
 
(8 intermediate revisions by 6 users not shown)
Line 1:
require('Module:No globalsstrict')
return setmetatable({}, {
__index = function(t, fk)
local what = mw.ustring[k]
if type(what) ~= "function" then
return what
end
return function(frame)
iflocal nilfargs == mwframe.ustring[f] thenargs
local fargsused = { tag = true }
return '<strong class="error">'..mw.message.new('scribunto-common-nosuchfunction', '', f):plain()..'</strong>'
local tagargsargs = {}
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
if 'function' ~= type(mw.ustring[f]) then
fargsused[i] = true
return '<strong class="error">'..mw.message.new('scribunto-common-notafunction', '', f):plain()..'</strong>'
args[i + str_i - 1] = tonumber(v) or v:gsub("^\\", "", 1)
end
if not fargs.tag then
local args = frame.args
return (what(unpack(args))) -- Outside parens truncate to first result avoiding tail call
for i, v in ipairs(args) do
args[i] = tonumber(v) or v:gsub("^\\", "", 1)
end
iflocal args.tagtagargs then= {}
for kx, vy in pairs(argsfargs) do
local tagargs = {}
if 'number'not ~= type(k) and 'tag' ~= kfargsused[x] then tagargs[kx] = vy end
for k, v in pairs(args) do
if 'number' ~= type(k) and 'tag' ~= k then tagargs[k] = v end
end
return frame:extensionTag{name = args.tag, content = mw.ustring[f](unpack(args)), args = tagargs}
end
return (mwframe:extensionTag{name = fargs.ustring[f]tag, content = what(unpack(args))), args = tagargs}
end
end