יחידה:ParamValidator: הבדלים בין גרסאות בדף

DK
מ גרסה אחת של הדף wikipedia:he:יחידה:ParamValidator יובאה
 
(4 גרסאות ביניים של 3 משתמשים אינן מוצגות)
שורה 110: שורה 110:
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
,  
,  
extract_options = function ( frame, optionsPrefix )
extract_options = function( frame, optionsPrefix )
optionsPrefix = optionsPrefix or 'options'  
optionsPrefix = optionsPrefix or 'options'  
שורה 272: שורה 272:


-- wraps report in hidden frame
-- wraps report in hidden frame
function wrapReport(report, template_name, options)
local function wrapReport(report, template_name, options)
if util.empty( report ) then return '' end
if util.empty( report ) then return '' end
local naked = mw.title.new( template_name )['text']  
local naked = mw.title.new( template_name )['text']  
שורה 287: שורה 287:


-- this is the "user" version, called with {{#invoke:}} returns a string, as defined by the options parameter
-- this is the "user" version, called with {{#invoke:}} returns a string, as defined by the options parameter
function validateParams( frame )
local function validateParams( frame )
-- for purple pages:
-- for purple pages:
שורה 301: שורה 301:


local replace_macros = function( s, param_names )
local replace_macros = function( s, param_names )
function concat_and_escape( t )  
local function concat_and_escape( t )  
local s = table.concat( t, ', ' )
local s = table.concat( t, ', ' )
return ( mw.ustring.gsub( s, '%%', '%%%%' ) )
return ( mw.ustring.gsub( s, '%%', '%%%%' ) )