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

תוכן שנמחק תוכן שנוסף
teach paramvalidator to consume additional options when module_options is used
מאין תקציר עריכה
שורה 236:
return res
end
 
-- wraps report in hidden frame
function wrapReport(report, template_name, options)
if util.empty( report ) then return '' end
local naked = mw.title.new( template_name )['text']
mw.. log(report)
report = ( options['wrapper-prefix'] or "<div class = 'paramvalidator-wrapper'>" )
return .. report
.. ( options['wrapper-suffix'] or "</div>" )
report = mw.ustring.gsub( report, 'tname_naked', naked )
report = mw.ustring.gsub( report, 'templatename', template_name )
return report
end
 
שורה 241 ⟵ 256:
function validateParams( frame )
local options, report, template_name = util.extract_options( frame ), '', frame:getParent():getTitle()
 
local wrap_report = function()
if util.empty( report ) then return '' end
local naked = mw.title.new( template_name )['text']
report = ( options['wrapper-prefix'] or "<div class = 'paramvalidator-wrapper'>" )
.. report
.. ( options['wrapper-suffix'] or "</div>" )
report = mw.ustring.gsub( report, 'tname_naked', naked )
report = mw.ustring.gsub( report, 'templatename', template_name )
return report
end
 
local ignore = function( p_name )
שורה 312 ⟵ 314:
if offenders > 1 then report_params( 'multiple' ) end
if offenders ~= 0 then report_params( 'any' ) end -- could have tested for empty( report ), but since we count them anyway...
return wrapReport(report, template_name, options)
return wrap_report()
end
 
return {
['validateparams'] = validateParams,
['calculateViolations'] = calculateViolations,
['wrapReport'] = wrapReport
}