FANDOM


If statements are used only in templates. They're for when you want the code to have a different outcome depending on what value a variable is given.

  • If statements may be stacked and used inside each each other.
  • Any of the outcomes spots may be left blank so that outcome is nothing.

#ifEdit

This one has two outcomes: One if a certain variable has a value, and one if not.

{{#if: {{{Variable|}}}
 |response if variable ISN'T empty
 |response if variable IS empty
}}

When the template is used, if it says |Variable = Anything at all, then the first field will be shown. If not, the second field will be shown.

#ifeqEdit

This one has two outcomes: One if a certain variable has a specific value, and one if not.

{{#ifeq: {{{Variable|}}}
 |potential value
 |response if variable is the potential value
 |response if variable is something else
}}

When the template is used, if it says |Variable = potential value, then the first field will be shown. If not, the second field will be shown.

#switchEdit

If you have more than one specific response for more than one specific value, use this one.

{{#switch: {{{Variable}}}
 |Value1 = Response for Value1
 |Value2 = Response for Value2
 |#default = Response if variable doesn't equal any of them
}}

When the template is used, the response for whatever value is given to the variable will be shown, and the default one if it doesn't fill any of the others. The default field is optional, and if there isn't one, then the default response is blank.

#ifexprEdit

This one has two outcomes: One if a number variable fulfills a certain mathematical expression, and one if it doesn't.

{{#ifexpr: {{#expr: {{{Variable}}} > or < a number or something }}
 |response if variable fulfill expression
 |response if variable DOESN'T fulfill expression
}}

For example, say the expression is {{#expr: {{{Variable}}} < 10}}.
Then if |Variable = 7 will get the first response, and |Variable = 22 will get the second one.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.