Editing Module:ParamtestGive feedback
Jump to navigation
Jump to search
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision | Your text | ||
| Line 1: | Line 1: | ||
-- | -- | ||
-- Tests basic properties of parameters | -- Tests basic properties of parameters | ||
| Line 26: | Line 9: | ||
-- | -- | ||
function p.is_empty(arg) | function p.is_empty( arg ) | ||
if not arg or not arg:find('%S') then | |||
return true | |||
end | |||
return false | |||
end | end | ||
-- | -- | ||
-- | -- Tests if the parameter has content | ||
-- The same as !is_empty, but this is more readily clear | |||
-- | -- | ||
function p. | function p.has_content( arg ) | ||
if | if not arg or not arg:find('%S') then | ||
return | return false | ||
end | end | ||
return true | |||
end | end | ||
-- | -- | ||
-- | -- Tests if the parameter has been defined (regardless of content) | ||
-- | -- | ||
function p. | |||
function p.is_defined( arg ) | |||
if not arg then | |||
return false | |||
else | |||
return true | |||
end | end | ||
end | end | ||
-- | -- | ||
-- | -- Removes leading and trailing whitespace from the parameter | ||
-- | -- Which is unfortunately not removed when passed through invoke | ||
-- | -- | ||
function p. | function p.trim( arg ) | ||
return string. | return string.gsub( arg, '^%s*(%S+)%s*$', '%1') | ||
end | end | ||
| Line 71: | Line 55: | ||
-- | -- | ||
function p.ucfirst(arg) | function p.ucfirst( arg ) | ||
if not arg or arg:len() == 0 then | if not arg or arg:len() == 0 then | ||
return nil | return nil | ||
| Line 85: | Line 69: | ||
-- | -- | ||
function p.ucflc(arg) | function p.ucflc( arg ) | ||
if not arg or arg:len() == 0 then | if not arg or arg:len() == 0 then | ||
return nil | return nil | ||