Help:Parser function basics

From Ballotpedia
Jump to: navigation, search
Ballotpedia:WikiProject Help

Parser functions are wiki tools that are designed to allow you to create logic statements on the wiki that will alter the results of a page based upon certain factors or arguments indicated in the parser function. This page will go over parser basics and provide examples of common parsers.

Parsers are most commonly used within advanced templates involving individual parameters. For more information on using DPLs with templates, see Help:DPL using templates.

Using parsers

Parser functions all begin with “{{#NAME:” where NAME is the function being called. Parser functions end with “}}” much like a template.

Common parsers

The most common parser functions in use include:

  • Expression parser
  • {{#expr: 5 + 2}} =This is a basic math parser and can be used to add, substract, multiply divide or round numbers entered on the wiki.
  • If parser
  • {{#if:X|Y|Z}} = If X is defined, then display Y. If not, display Z. A parameter is defined if your template call includes {{Template Name|X=Some text}} .
  • If equals parser
  • {{#ifeq:A|B|X|Y}} = If A is defined as B, then display X. If not, display Y. A parameter is defined specifically if your template call includes {{Template Name|A=B}} .
  • Switch parser
  • {{#switch:A|B=X|C=Y|D=Z}} = If A is defined as B, then display X. If A is defined as C, then display Y. If A is defined as D, then display Z. A parameter is defined specifically if your template call includes {{Template Name|A=B}} .

DPLs

Parsers can also be used with DPLs to manipulate the information summoned in a DPL call. However, a perser included in the DPL call must be incorporated via a third template call within the "secseparators" section of the DPL code.

Advanced parser notes

Parsers may be nested inside each other. However, be sure to close your brackets accordingly.

List of parser pages

See also

External links

References