Content deleted Content added
update |
+ countNotEmpty |
||
Line 1:
--[=[ TemplatePar 2013-05-
Template parameter utility
* check
* count
* countNotEmpty
* downcase
* valid
Line 661 ⟶ 662:
return r
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()
Line 772 ⟶ 794:
return tostring( TemplatePar.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()
|