Help:Parser Functions

Parser Functions are more advanced wiki coding that serve as "tests" in Templates. Using these Parser Functions allows for more complicated templates that provide better design and appeal for the wiki.


[edit] #if

{{#if: Expression | True Result | False Result}}

#if allows users to test for contents within the first parameter. If it is filled, it will display the information within the second parameter. If the test result is empty, it will call the information in the third parameter. This will also occur if the first parameter is filled with "empty contents", such as spaces.

Any parameters can be omitted if necessary, allowing for empty results or tests.

[edit] Examples

Test Result
{{#if: True | True | False}} True
{{#if: True | | False}}
{{#if: | True | False}} False

[edit] #ifeq

{{#ifeq: Expression 1 | Expression 2 | Equal Result | Not Equal Result}}

#ifeq allows an output to be stated based on whether it equals a pre-defined input or not. If the first parameter and second parameter are equal (the same), the third parameter will be outputted. If not, the fourth parameter will show. This parser functions works with both numbers and words.

[edit] Examples

Test Result
{{#ifeq: 1 | 2 | Equal | Not Equal}} Not Equal
{{#ifeq: 0 | 0 | Equal | Not Equal}} Equal
{{#ifeq: Yes | Yes | Equal | Not Equal}} Equal
{{#ifeq: 47 | Green | Yes |}}

[edit] #ifexpr

{{#ifexpr: Expression | True Result | False Result}}

#ifexpr is used to check whether or not a written expression is true. It is similar to #expr, but will not solve problems such as 1 + 1. Instead, it will check for things such as equal to.

Expression is where you will input the code you'd like to check (ex. 2 > 1), True Result would be the output if that was correct and False Result would be the output if it was incorrect.

[edit] Examples

Test Result
{{#ifexpr: 2 = 2 | Yes | No}} Yes
{{#ifexpr: 4 < 7 | Yes | No}} Yes
{{#ifexpr: 7 > 9 | Yes | No}} No

[edit] Template Examples

For Template Examples of any Parser Function, check out the Parser Functions in Templates page. It provides practical examples of all of the parser functions mixed together and alone in different hypothetical templates.