Module:Params/doc: Difference between revisions

Content deleted Content added
trimmed: Move suggestion below and expand it
Use {{tj}} when showing template examples
Line 16:
and such template were called with the following arguments,
 
<syntaxhighlight lang="wikitext">{{tj|Example template|Beast of Bodmin=: A large feline inhabiting Bodmin Moor.
|Morgawr=: A sea serpent.|Owlman=: A giant owl-like creature.}}</syntaxhighlight>
 
the following result would be produced:
Line 111 ⟶ 112:
<syntaxhighlight lang="wikitext">{{#invoke:params|concat_and_call|foo bar|elbow|earth|room|7=classy|hello=not today}}</syntaxhighlight>
 
and it were called with,
 
<syntaxhighlight lang="wikitext">{{exampletj|Example template|one|two|three|hello=: world|wind=: spicy}}</syntaxhighlight>
 
the following call to the <code><nowiki>{{Foo bar}}</nowiki></code> template would be performed:
 
<syntaxhighlight lang="wikitext">{{footj|Foo bar|elbow|earth|room|7=: classy|8=: one|9=: two|10=three|wind=spicy|hello=not: today}}</syntaxhighlight>three
|wind: spicy|hello: not today}}
 
If no other argument besides the template name are provided this function simply echoes the current parameters to another template.
Line 318 ⟶ 320:
}}</syntaxhighlight>
 
{{A note|Suggestion:}} Although <syntaxhighlight lang="wikitext" inline>{{#invoke:params|trimmed|-1|1|...}}</syntaxhighlight> de facto gets rid of all sequential parameters, it is clearer and more idiomatic to write <syntaxhighlight lang="wikitext" inline>{{#invoke:params|non-sequential|...}}</syntaxhighlight> to obtain the same effect. Writing <syntaxhighlight lang="wikitext" inline>{{#invoke:params|sequential|trimmed|-1|1|...}}</syntaxhighlight> will haveleave zero arguments leftto show.
 
{{vpad}}