Module:TemplatePar: Difference between revisions

Content deleted Content added
update
update
Line 1:
--[=[ TemplatePar 2013-05-2022
Template parameter utility
* check
Line 81:
[ "+" ] = "%S"
}
 
 
 
function trim( s )
-- Trim string
-- Precondition:
-- s -- string or nil; to be trimmed
-- Postcondition:
-- Return trimmed string or nil
if type( s ) == "string" then
if s:match( "^%s*$" ) then
s = ""
else
s = s:match( "^%s*(%S.*)$" ):match( "^(.*%S)%s*$" )
end
end
return s
end -- trim()
 
 
Line 554 ⟶ 536:
-- frame:getParent()
-- failure()
-- mw.text.trim()
-- failsafe()
local r = false
Line 577 ⟶ 560:
else
if type( options.key ) == "string" then
s = mw.text.trim( options.key )
else
s = "+"
Line 708 ⟶ 691:
-- false if valid or no answer permitted
-- Uses:
-- mw.text.trim()
-- format()
-- failure()
Line 714 ⟶ 697:
local r
if type( seek ) == "string" then
r = mw.text.trim( seek )
if #r == 0 then
r = false
Line 800 ⟶ 783:
-- Uses:
-- form()
-- mw.text.trim()
-- TemplatePar.valid()
local options = { mandatory = { "1" },
Line 814 ⟶ 797:
local r = form( false, options )
if not r then
local s = mw.text.trim( frame.args[ 2 ] )
options = { cat = frame.args.cat,
low = frame.args.low,