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

תוכן שנמחק תוכן שנוסף
ניסוי
הרחבה של התיעוד בגוף היחידה
שורה 4:
 
the source of this module is in //he.wikipedia.org/wiki/Module:ParamValidator
 
main purpose: use "templatedata" to verify the parameters passed to a template
 
Terminology: "numeric parameter" means order-based parameter. e.g. if the template is transcluded like so {{x | k | | a = m | b = }}
"a" and "b" are "named" parameters, and there are 2 "numeric", or order based parameters, 1 and 2.
we say that the value of a is "m", the value of 1 is "k", and "b" and 2 are "empty".
 
This module exports two functions: calculateViolations( frame, subpages ), and validateParams( frame ).
שורה 38 ⟵ 44:
 
at the top of the template (be mindful not to add extra spaces and newlines to the template).
to bypass some mediawiki limitation, it is also possible to pass the options as "module", like so (use one of the two, but not both):
<includeonly>{{#invoke:ParamValidator | validateParams | module_options = Module:PV default options}} }}</includeonly>
 
the first form expects a template named "Template:PV default options" which contains the options, and the 2nd form expects a module,
suitable for mw.loadData(), which returns a map of namespace => options (i.e. { [0] = <options>, [2] => <options> } .... )
 
the options parameter should be a JSON-encoded string, defining the output, and some special behaviors.