PGI logo cropped.png
Congressional Millionaire’s Club
The Personal Gain Index shines a light on how members of Congress benefit during their tenure.





Help:If parser

From Ballotpedia
Jump to: navigation, search

If parsers are used to create commands that will post certain information on a wiki page if and only if other information is supplied.

If Parser basics

  • Establish what happens if a certain parameter is defined as anything.
  • Useful for choosing to include or not include lines on a table.
  • Fails to differentiate between different ways to define the parameter.

If parser code

The code on the template page reads:
{{#if: {{{Parameter|}}} | WHAT WILL RENDER IF DEFINED | WHAT WILL RENDER IF UNDEFINED }}
[1]



The template code example is:
{{#if: {{{Parameter}}} | Hello World | Good bye world }}



The Template call:
{{Template name|Parameter = Yes/No/Anything}} versus {{Template name}} or {{Template name|Parameter = }}



The result:
Hello World versus Good bye world

Advanced if-parser notes

  • If parsers are most useful to limiting information on templates to only information that we have access too. This keeps our templates short when we have minimal information but provides the opportunity for expansion when more information is available.

References