Topic on Project:Support desk

Is it a best practice to explicitly call all parameters in template-calls in MediaWiki templates?

6
182.232.57.75 (talkcontribs)

In an RTL (Hebrew) MediaWiki 1.34.0 website with Cite extension and ParserFunctions extension loaded in LocalSettings.php I use the following template to create references for English text.


Template:Cite

<includeonly>{{#if:{{{name|}}}
    | {{#tag:ref|{{{content|}}}|name={{{name}}}}}
    | {{#tag:ref|{{{content|}}}}}
}}</includeonly>

Credit for @Johnatan3 for essentially developing the above template.

Calling Template:Cite

Input

First check{{Cite|content=First check}}
Second check{{Cite|content=Second check|name=First_name}}
Third check {{Cite|name=First_name}}

<references />

Output

First check Second check Third check

  1. ^ First check
  2. ^ לקפוץ מעלה אל:2.0 2.1 Second check

My problem

I don't know if it's a best practice to explicitly call parameters (or at least, all parameters) when calling a template in MediaWiki;

For example, in Hebrew Wikipedia I have seldom created references for articles and when these references were named (i.e contain a name HTML attribute) I just wrote:

{{הערה|מידע_ההערה|שם=xyz}}

I didn't put a parameter call such as תוכן= (content=) before מידע_ההערה (REFERENCE_INFORMATION) but rather, only before שם ("name"). If I would explicitly call all parameters in a the template call we would have:

{{הערה|תוכן=מידע_ההערה|שם=xyz}}

But Hebrew Wikipedia allows to omit the first parameter call somehow (perhaps based on the fact that it's the first parameter call).

My question

Is it a best practice to explicitly call all parameters in template-calls in MediaWiki templates?

@Johnatan3 wouldn't you prefer to make it redundant to call content= (i.e תוכן=) at least in cases were it is the first parameter?

Jonathan3 (talkcontribs)

It's just how the code developed in the other thread, but you could change it to:

<includeonly>{{#if:{{{name|}}}
| {{#tag:ref|{{{1|}}}|name={{{name}}}}}
| {{#tag:ref|{{{1|}}}}}
}}</includeonly>

Then you would call it as you suggest (i.e. the "name" parameter has to be stated as "name=" but the content parameter just has to be the first parameter).

Jonathan3 (talkcontribs)

This wouldn't work if you do it the wrong way round, e.g. {{cite | name = greetings | how do you do}}. I think that's because there is no {{{1}}} parameter in that case.

182.232.4.49 (talkcontribs)

@Jonathan3

Your guidance inspires me; I thank you for coming to my aid in these graceful, didactic ways;

I hope other users will take example from you !

With great appreciation.


Jonathan3 (talkcontribs)

Thank you very much - you're welcome :-)

Jonathan3 (talkcontribs)

P.S. I said:

This wouldn't work if you do it the wrong way round, e.g. {{cite | name = greetings | how do you do}}. I think that's because there is no {{{1}}} parameter in that case.

But I've just tried it again and it works all right either way...

Reply to "Is it a best practice to explicitly call all parameters in template-calls in MediaWiki templates?"