Mabinogi World Wiki is brought to you by Charlie C., Coty C., our other patrons, and contributors like you!!
Want to make the wiki better? Contribute towards getting larger projects done on our Patreon!

Template:Ifempty

From Mabinogi World Wiki
Jump to: navigation, search
[edit]Template Documentation

Description

This is the {{ifempty}} template.

This template is used inside other templates. It takes up to nine parameters (parameters 1-9), and returns the first one that is defined and non-empty, otherwise nothing. Typical usage is like this:

{{ifempty | {{{logo|}}} | {{{image|}}} | default.svg}}

This returns the first of the parameters logo and image that is defined and non-empty, otherwise "default.svg".

Background

The MediaWiki parameter default function doesn't return the default value for empty parameters. That is, {{{logo|default.svg}}} does not return "default.svg" if the template was called like this: {{template|logo=}}.

The usual workaround is to do like this:

{{#if: {{{logo|}}} | {{{logo}}} | default.svg}}

But this becomes complex when you want to check several parameters:

{{#if: {{{logo|}}} | {{{logo}}} | {{#if: {{{image|}}} | {{{image}}} | default.svg}}}}

Then it is easier to use this template instead:

{{ifempty | {{{logo|}}} | {{{image|}}} | default.svg}}
Note! The parameters to {{ifempty}} must use the pipe "|", like this: {{{logo|}}}. Or else {{ifempty}} will be fed and return the string "{{{logo}}}" if logo was not defined.