Jump to content

Module:Ustring

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Pppery (talk | contribs) at 12:34, 8 March 2019 (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). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

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

return p