Módulo:Xpsoc

Revisão em 01h40min de 14 de maio de 2024 por Jaewoo (discussão | contribs) (Criou a página com "-- This module implements {{xpsoc}}. local mTemplateInvocation = require('Módulo:Template invocation') local p = {} function p._main(args, frame) frame = frame or mw.getCurrentFrame() -- Get the invocation arguments. local name = args[1] if not name then error('sem nome de predefinição passado a xpsoc', 2) end local invArgs = {} for k, v in pairs(args) do if k ~= 1 then if type(k) == 'number' then invArgs[k - 1] = v else local num = k:match(...")
(dif) ← Revisão anterior | Revisão atual (dif) | Revisão seguinte → (dif)

A documentação para este módulo pode ser criada na página Módulo:Xpsoc/doc

-- This module implements {{xpsoc}}.
local mTemplateInvocation = require('Módulo:Template invocation')
local p = {}
function p._main(args, frame)
	frame = frame or mw.getCurrentFrame()
	-- Get the invocation arguments.
	local name = args[1]
	if not name then
		error('sem nome de predefinição passado a xpsoc', 2)
	end
	local invArgs = {}
	for k, v in pairs(args) do
		if k ~= 1 then
			if type(k) == 'number' then
				invArgs[k - 1] = v
			else
				local num = k:match('^n([1-9][0-9]*)$')
				if num then
					invArgs[args[k]] = args['v' .. num]
				end
			end
		end
	end
	local invocation = mTemplateInvocation.invocation(name, invArgs, 'nowiki')
	local gives = args.gives or mw.language.getContentLanguage():getArrow('forwards')
	local result = frame:preprocess(mTemplateInvocation.invocation(name, invArgs))
	
	return string.format('<code>%s</code> %s %s', invocation, gives, result)
end
function p.main(frame)
	return p._main(frame:getParent().args, frame)
end
return p