Template:If/doc

From Australian sf information
Jump to: navigation, search

With this template the parser functions of the ParserFunctions collection with names starting with "#if" can be used in a way such that they do not strip spaces and newlines from the "then" and "else" part. Spaces still do not affect the outcome of the condition.

Usage

  • {{if||x| p | q }} gives "Template:P2"
  • {{if|expr|2<3| p | q }} gives " p "
  • {{if|eq| u |u| p | q }} gives "Template:P1"
  • {{if|exist| Help:Link | p | q }} gives "Template:P2"
  • {{if|error|{{#expr:x}}| p | q }} gives "Template:P2"

Compare:

  • {{#if:x| p | q }} gives "p"
  • {{#ifexpr:2<3| p | q }} gives "p"
  • {{#ifeq: u |u| p | q }} gives "p"
  • {{#ifexist: Help:Link | p | q }} gives "q"
  • {{#iferror:{{#expr:x}}| p | q }} gives "p"

For full substitution, use e.g. {{subst:if|expr|2<3| p | q |subst=subst:}}. If the condition contains a parser function or template etc., that should be substituted too. Optionally the "then" or "else" part can also be substituted.
https://wiki.sf.org.au/Template:If/doc
wiki.sf.org.au
crawl=CC-MAIN-2021-39
14711
application/http; msgtype=response
sha1:MCP6UBF6TVL52G4YQNX6YA22RDO62TA3
<urn:uuid:a62e2c72-fb0f-41ba-9354-86b5415a96fe>
2021-09-24T06:11:03Z
173.230.252.29
text/html
sha1:54DDIMXMI275CUDU5TFB3F5QQKQZOFUM
<urn:uuid:f3926f5a-c396-4f65-a507-bcc65f1eed2d>
https://wiki.sf.org.au/Template:If/doc
response
<urn:uuid:01aafb50-7731-4561-b657-76be954344db>
isPartOf: CC-MAIN-2021-39
publisher: Common Crawl
description: Wide crawl of the web for September 2021
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-130
software: Apache Nutch 1.18 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.2-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/