"ഫലകം:If empty/doc" എന്ന താളിന്റെ പതിപ്പുകൾ തമ്മിലുള്ള വ്യത്യാസം

Intermediate save.
More documentation.
വരി 6:
This is a meta-template that is used inside other templates. It takes several parameters and returns the first one of them that is defined (not null) and not empty.
 
The MediaWiki parameter default function doesn't return the default value for empty parameters. That is, <code><nowiki>{{{logo|default.svg}}}</nowiki></code> does not return "default.svg" if the template was called like this: <code><nowiki>{{template|logo=}}</nowiki></code>.
=== Usage ===
 
The usual workaround is to do like this:
Old usage that sometimes fail:
:<code><nowiki>{{#if:{{{logo|}}}| {{{logo}}} | default.svg }}</nowiki></code>
<pre>
[[image:{{{logo|{{{image|default.png}}}}}} | 100px ]]
</pre>
 
But this becomes complex when you want to check several parameters:
This will fail if ''logo'' or ''image'' is empty but defined, for instance if a template is called like this: <code><nowiki>{{template|logo=}}</nowiki></code>
 
Using {{tl|ifempty}} solves this:
 
<pre>
[[image:{{ifempty | {{{logo|}}} | {{{image|}}} | default.png }} | 100px ]]
</pre>
 
:<code><nowiki>{{#if:{{{logo|}}}| {{{logo}}} | {{#if:{{{image|}}} | {{{image}}} | default.svg }}}}</nowiki></code>
 
Then it is easier to use this template instead:
 
[[image:<code><nowiki>{{ifempty | {{{logo|}}} | {{{image|}}} | default.pngsvg }} | 100px ]]</nowiki></code>
 
=== Examples ===
"https://ml.wikipedia.org/wiki/ഫലകം:If_empty/doc" എന്ന താളിൽനിന്ന് ശേഖരിച്ചത്