יחידה:ParamValidator: הבדלים בין גרסאות בדף
תוכן שנמחק תוכן שנוסף
תיעוד |
הוצאת פונקציות שירות ליחידה נפרדת |
||
שורה 96:
]=]
local util = require( 'Module:Utility' )
-- this is the function to be called by other modules. it expects the frame, and then an optional list of subpages, e.g. { "Documentation" }.
שורה 135 ⟵ 110:
local t_frame = frame:getParent()
local t_args, template_name = t_frame.args, t_frame:getTitle()
local td_source = util.build_namelist( template_name, subpages )
local templatedata = require( 'Module:ReadTd' ).ReadTemplateData( td_source )
local td_params = templatedata and templatedata.params
שורה 146 ⟵ 121:
-- handle undeclared and deprecated
for p_name, value in pairs( t_args ) do
local tp_param, noval, numeric, table_name = td_params[p_name], util.empty( value ), tonumber( p_name )
if not tp_param then -- not in TD: this is called undeclared
שורה 169 ⟵ 144:
-- test for empty/missing paraeters declared "required"
for p_name, param in pairs( td_params ) do
if param.required and util.empty( t_args[p_name] ) then
res['empty-required'] = res['empty-required'] or {}
res['empty-required'][p_name] = ''
שורה 180 ⟵ 155:
-- this is the "user" version, called with {{#invoke:}} returns a string, as defined by the options parameter
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']
|