Jump to content

Module:Ustring

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Uzume (talk | contribs) at 23:58, 30 April 2020 (minor optimizations by avoiding extraneous multi-table references and returning most common cases first). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

require('Module:No globals')
return setmetatable({}, {
	__index = function(t, k)
		local what = mw.ustring[k]
		if type(what) ~= "function" then
			return what
		end
		return function(frame)
			local args = frame.args
			for _, v in ipairs(args) do
				args[_] = tonumber(v) or v:gsub("^\\", "", 1)
			end
			if not args.tag then
				return (what(unpack(args)))
			end
			local tagargs = {}
			for x, y in pairs(args) do
				if type(x) ~= 'number' and x ~= 'tag' then tagargs[x] = y end
			end
			return frame:extensionTag{name = args.tag, content = what(unpack(args)), args = tagargs}
		end
	end
})