• Home
  • Random
  • Recent changes
  • Special pages
  • Settings
  • About MOASSpedia
  • Disclaimers
MOASSpedia
  • 216.73.216.55
  • Talk
  • Watchlist
  • Contributions
  • Log in

Template:Ifnoteq then show

Template Discussion
  • Language
  • Watch
  • History
  • Edit
    • Page information
    • Permanent link
    • What links here
Template documentation[view] [edit] [history] [purge]

This template tests whether the first unnamed parameter is equal to the second unnamed parameter and returns the third unnamed parameter if it does. Otherwise it returns the first unnamed parameter.

This is useful when the first parameter is a {{#invoke: }} of a Lua module that returns a value for which a specific exception is required. Because it uses the {{#invoke: }} just once, it simplifies the coding of infoboxes, for example.

Usage

An infobox field may return the Lua error in Module:Wd at line 196: attempt to index field 'wikibase' (a nil value). (P17) for an article about a city. We may wish to use the abbreviation "USA" in place of "United States".

Lua error in Module:Wd at line 196: attempt to index field 'wikibase' (a nil value). (P17) for Lua error in Module:Wd at line 196: attempt to index field 'wikibase' (a nil value). (Q42462)
{{#invoke:WikidataIB |getValue |P17 |qid=Q42462 |fwd=ALL |osd=no |rank=best |noicon=true}} →
{{Ifnoteq then show|{{#invoke:WikidataIB |getValue |P17 |qid=Q42462 |fwd=ALL |osd=no |rank=best |noicon=true}}|United Kingdom|UK}} →
Lua error in Module:Wd at line 196: attempt to index field 'wikibase' (a nil value). (P17) for Lua error in Module:Wd at line 196: attempt to index field 'wikibase' (a nil value). (Q60)
{{#invoke:WikidataIB |getValue |P17 |qid=Q60 |fwd=ALL |osd=no |rank=best |noicon=true}} →
{{Ifnoteq then show|{{#invoke:WikidataIB |getValue |P17 |qid=Q60 |fwd=ALL |osd=no |rank=best |noicon=true}}|United States|USA}} →
The above documentation is transcluded from Template:Ifnoteq then show/doc. (edit | history)
Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages.
Add categories to the /doc subpage. Subpages of this template.
Retrieved from "https://moasspedia.org/w/index.php?title=Template:Ifnoteq_then_show&oldid=19186"
Categories:
  • Pages with script errors
  • If-then-else templates
Last edited on 17 December 2020, at 12:59

MOASSpedia

Content is available under Creative Commons Attribution-ShareAlike unless otherwise noted.
  • This page was last edited on 17 December 2020, at 12:59.
  • Content is available under Creative Commons Attribution-ShareAlike unless otherwise noted.
  • Privacy policy
  • About MOASSpedia
  • Disclaimers
  • Desktop