יחידה:ParamValidator – הבדלי גרסאות

שיע.ק (שיחה | תרומות)
ז
אין תקציר עריכה
 
שורה 1: שורה 1:
require('strict')
--[=[
--[=[


שורה 110: שורה 111:
local util = {
local util = {
empty = function( s )  
empty = function( s )  
return s == nil  or type( s ) == 'string' and mw.text.trim( s ) == ''   
return s == nil  or type( s ) == 'string' and (mw.text.trim( s ) == '' or s == '-') -- compatible with module:תבנית מידע    
end
end
,  
,  
שורה 117: שורה 118:


local options, n, more = {}
local options, n = {}
if frame.args['module_options'] then
if frame.args['module_options'] then
local module_options = mw.loadData( frame.args['module_options'] )  
local module_options = mw.loadData( frame.args['module_options'] )  
שורה 127: שורה 128:
repeat
repeat
ok, more = pcall( mw.text.jsonDecode, frame.args[optionsPrefix .. ( n or '' )] )
local ok, more = pcall( mw.text.jsonDecode, frame.args[optionsPrefix .. ( n or '' )] )
if ok and type( more ) == 'table' then
if ok and type( more ) == 'table' then
for k, v in pairs( more ) do options[k] = v end
for k, v in pairs( more ) do options[k] = v end
שורה 148: שורה 149:
table_empty = function( t ) -- normally, test if next(t) is nil, but for some perverse reason, non-empty tables returned by loadData return nil...
table_empty = function( t ) -- normally, test if next(t) is nil, but for some perverse reason, non-empty tables returned by loadData return nil...
if type( t ) ~= 'table' then return true end
if type( t ) ~= 'table' then return true end
for a, b in pairs( t ) do return false end
for _, _ in pairs( t ) do return false end
return true
return true
end
end