Modul:TemplatePar: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
+ countNotEmpty
wp>PerfektesChaos (update) |
wp>PerfektesChaos (+ countNotEmpty) |
||
Zeile 1: | Zeile 1: | ||
--[=[ TemplatePar 2013-05- | --[=[ TemplatePar 2013-05-26 | ||
Template parameter utility | Template parameter utility | ||
* check | * check | ||
* count | * count | ||
* countNotEmpty | |||
* downcase | * downcase | ||
* valid | * valid | ||
Zeile 661: | Zeile 662: | ||
return r | return r | ||
end -- TemplatePar.count() | end -- TemplatePar.count() | ||
TemplatePar.countNotEmpty = function () | |||
-- Return number of template parameters with more than whitespace | |||
-- Postcondition: | |||
-- Return number, starting at 0 | |||
-- Uses: | |||
-- mw.getCurrentFrame() | |||
-- frame:getParent() | |||
local k, v | |||
local r = 0 | |||
local t = mw.getCurrentFrame():getParent() | |||
local o = t.args | |||
for k, v in pairs( o ) do | |||
if not v:match( "^%s*$" ) then | |||
r = r + 1 | |||
end | |||
end -- for k, v | |||
return r | |||
end -- TemplatePar.countNotEmpty() | |||
Zeile 772: | Zeile 794: | ||
return tostring( TemplatePar.count() ) | return tostring( TemplatePar.count() ) | ||
end -- .count() | end -- .count() | ||
function p.countNotEmpty( frame ) | |||
-- Count number of template parameters which are not empty | |||
-- Postcondition: | |||
-- Return string with digits including "0" | |||
-- Uses: | |||
-- TemplatePar.countNotEmpty() | |||
return tostring( TemplatePar.countNotEmpty() ) | |||
end -- .countNotEmpty() | |||