Module:TemplatePar: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
fix content model
2015-02-14
Line 1:
--[=[ TemplatePar 2015-0102-1614
Template parameter utility
* assert
Line 11:
* TemplatePar()
]=]
 
 
 
-- Module globals
Line 308 ⟶ 310:
if type( scan ) == "string" then
if s == "n" or s == "0,0" or s == "0.0" then
if not analyze:match( "[0-9]" ) then and
not analyze:match( "^%s*$" ) then
scan = false
if options.say then
Line 549 ⟶ 552:
if type( s ) == "string" and
s ~= "" and s ~= "0" and s ~= "-" then
lazyif =lazy falsethen
options = { } show = ""
options.say lazy = accessfalse
end
if not frame then
frame = mw.getCurrentFrame()
end
if frame:preprocess( "{{REVISIONID}}" ) == "" then
if s ~== "1" then
show = "*"
else
show = s
end
Line 588 ⟶ 596:
s = opt.cat
if type( s ) == "string" then
if not ropt.errNS then
r local ns = ""mw.title.getCurrentTitle().namespace
end local st = type( opt.errNS )
if s:find(st == "@@@string" ) then
if type( opt.template ) =local space = "string.format( ".*%%s%d%%s.*", thenns )
slocal spaces = s:gsubstring.format( "@@@ %s ", opt.templateerrNS )
if spaces:match( space ) then
opt.errNS = false
end
elseif st == "table" then
for i = 1, #opt.errNS do
if opt.errNS[ i ] == ns then
opt.errNS = false
break -- for i
end
end -- for i
end
end
localif iopt.errNS then
local cats = mw.text.split( s,r = "%s*#%s*" )
for i = 1, #cats doelse
sif =not mw.text.trim(r cats[ i ] )then
if #s > 0r then= ""
r = string.format( "%s[[Category:%s]]", r, s )
end
end -- for i if s:find( "@@@" ) then
if type( opt.template ) == "string" then
s = s:gsub( "@@@", opt.template )
end
end
r = format( story, optionslocal )i
local cats = mw.text.split( s, "%s*#%s*" )
for i = 1, #cats do
-- s = mw.text.trim( cats[ i ] )
if #s > 0 then
r = string.format( "%s[[Category:%s]]", r, s )
end
end -- for i
end
end
end
Line 825 ⟶ 855:
-- feasible()
-- failure()
local r = feasible( analyze, options, false )
local show
if options.min and not r then
Line 877 ⟶ 907:
-- false if valid or no answer permitted
-- Uses:
-- mw.getCurrentFrametext.trim()
-- format()
-- failure()
local r = false
if type( assignment ) == "table" then
local story = assignment.args[ access ] or ""
if type( storyaccess ) == "stringnumber" then
ifstory type= mw.text.trim( optionsstory ) ~= "table" then
options = { }
end
options.say = access
r = format( story, options )
else
r = failure( "invalid", access, options )
end
if type( options ) ~= "table" then
options = { }
end
options.say = access
r = failureformat( "invalid", accessstory, options )
end
return r
Line 906 ⟶ 936:
-- Uses:
-- form()
-- mw.text.trim()
-- failure()
-- finalize()
Line 914 ⟶ 943:
optional = { "2",
"cat",
"errNS",
"low",
"max",
Line 928 ⟶ 958:
local s
options = { cat = frame.args.cat,
errNS = frame.args.errNS,
low = frame.args.low,
format = frame.args.format,
Line 1,086 ⟶ 1,117:
-- mw.text.trim()
-- TemplatePar.downcase()
-- mw.getCurrentFrame()
-- frame:getParent()
-- formatted()
Line 1,165 ⟶ 1,195:
"opt",
"cat",
"errNS",
"low",
"format",
Line 1,176 ⟶ 1,207:
optional = fill( frame.args.opt ),
cat = frame.args.cat,
errNS = frame.args.errNS,
low = frame.args.low,
format = frame.args.format,
Line 1,226 ⟶ 1,258:
local r = false
local options = { cat = frame.args.cat,
errNS = frame.args.errNS,
low = frame.args.low,
format = frame.args.format,