Difference between revisions of "Template:Ifnoteq then show/doc"
Jump to navigation
Jump to search
imported>RexxS (documentation and example) |
imported>Mike Peel |
||
| Line 20: | Line 20: | ||
<includeonly>{{sandbox other|| | <includeonly>{{sandbox other|| | ||
<!-- Categories below this line, please; interwikis at Wikidata --> | <!-- Categories below this line, please; interwikis at Wikidata --> | ||
| − | + | [[Category:If-then-else templates]] | |
}}</includeonly> | }}</includeonly> | ||
Latest revision as of 18:57, 3 August 2018
| This is a documentation subpage for Template:Ifnoteq then show. It contains usage information, categories and other content that is not part of the original template page. |
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 States|United States]]|USA}}→
- 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|United States]]|USA}}→