Modul:Peralatan
Tampilan
local Peralatan = { }
function Peralatan.trim( text )
if type( text ) == 'string' and text ~= '' then
text = text:match( '^()%s*$' ) and '' or text:match( '^%s*(.*%S)' )
if text ~= '' then
return text
end
end
return nil
end
function Peralatan.validTextArg( args, name, ... )
local text = Peralatan.trim( args[name] )
if text then
return text
end
if select( '#', ... ) > 0 then
Peralatan.validTextArg( args, ... )
end
return nil
end
function Peralatan.notEmpty( var, ... )
local text = Peralatan.trim( var )
if text then
return text
end
local tvar = type( var )
if tvar == 'table' then
local nextFunc = pairs( var ) -- n'utilise pas next car non défini par mw.loadData
if nextFunc( var ) ~= nil then
return var
end
elseif var == true or ( tvar == 'number' and var ~= 0 ) or tvar == 'function' then
return var
end
if select( '#', ... ) > 0 then
return Peralatan.notEmpty( ... )
end
end
function Peralatan.extractArgs ( frame )
if type( frame.getParent ) == 'function' then
local args = frame:getParent().args
for k,v in pairs( frame.args ) do
args[k] = v;
end
return args
else
return frame
end
end
return Peralatan