Modul:Homokozó/Pepo41/ExampleArgs

A Wikipédiából, a szabad enciklopédiából

Homokozó/Pepo41/ExampleArgs[mi ez?] • [dokumentáció: mutat, szerkeszt] • [tesztek: létrehozás]

local getArgs = require('Modul:Homokozó/Pepo41/Arguments').getArgs

local p = {}
function p.main(frame)
	
local options = {
	 Trim_and_nil_for_empty  = false,  -- üreset nil értékűvé tesz, ez a default viselkedés
	 TrimOnly                = false, -- üres üres marad
	 Return_not_space_or_nil = false, -- nilt ad, ha csak szóköz van a stringben, a mást visszaadja
	 NoChange                = true, -- úgy marad minden, ahogyan a sablonban van
	 -- fentiek közül egy és csak egy lehet true
  	 frameOnly =  false,
	 parentOnly = false, -- választás kérdése
	 both =       true -- ha mindkettő kell
} 
    local ou = ''
	if options.frameOnly then
		local ou, metafargs = getArgs(frame, options)
		return p._main(ou, metafargs)	
	elseif options.parentOnly then
		local ou, metapargs = getArgs(frame, options)
		return p._main(ou, metapargs)
	elseif options.both then
		local ou, metafargs, metapargs = getArgs(frame, options)
		return p._main(ou, metafargs, metapargs)
	end	
end

function p._main(ou, ...)
	
	local s = ''
	local list = {...}
	for _, var in pairs(list) do
		local first = var[1] or ' nincs első'
		local second = var[2] or ' nincs második'
		s = s .. first..','.. second
	end	
	if ou then
		return ou .. ' ' .. s
	else
	    return s
	end
end

return p