Module:Params/doc: Difference between revisions

Content deleted Content added
trimmed: Add example
value_of: Document the new function
Line 57:
 
This function does not take arguments.
 
{{vpad|1.5em}}
 
=== <code>value_of</code> ===
; Brief
: ''Get the value of a single parameter''
; Syntax
: <syntaxhighlight lang="wikitext" inline>{{#invoke:params|value_of|parameter name}}</syntaxhighlight>
 
Without modifiers this function is similar to writing <syntaxhighlight lang="wikitext" inline>{{{parameter name|}}}</syntaxhighlight>. With modifiers, however, it allows to reach parameters that would be unreachable without knowing their number in advance. For instance, writing
 
<syntaxhighlight lang="wikitext">{{#invoke:params|trimmed|-2|0|value_of|1}}</syntaxhighlight>
 
will write the value of the second-last sequential parameter, independently of how many parameters the template was called with. If no matching parameter is found this function expands to nothing.
 
{{vpad|1.5em}}