模板:Ifnoteq then show/doc
跳至導覽
跳至搜尋
| File:Edit-copy green.svg | 此頁面是Template:Ifnoteq then show的模板文件。 此頁面可能包含了模板的使用說明、分類和其他內容。 |
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.
用法[編輯]
An infobox field may return the Module:Wikibase第27行Lua錯誤: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".
- Module:Wikibase第27行Lua錯誤:attempt to index field 'wikibase' (a nil value) (P17) for Module:Wikibase第27行Lua錯誤:attempt to index field 'wikibase' (a nil value) (Q42462)
{{#invoke:WikidataIB |getValue |P17 |qid=Q42462 |fwd=ALL |osd=no |rank=best |noicon=true}}→ Module:WikidataIB第759行Lua錯誤:attempt to index field 'wikibase' (a nil value){{Ifnoteq then show|{{#invoke:WikidataIB |getValue |P17 |qid=Q42462 |fwd=ALL |osd=no |rank=best |noicon=true}}|United Kingdom|UK}}→ Module:WikidataIB第759行Lua錯誤:attempt to index field 'wikibase' (a nil value)
- Module:Wikibase第27行Lua錯誤:attempt to index field 'wikibase' (a nil value) (P17) for Module:Wikibase第27行Lua錯誤:attempt to index field 'wikibase' (a nil value) (Q60)
{{#invoke:WikidataIB |getValue |P17 |qid=Q60 |fwd=ALL |osd=no |rank=best |noicon=true}}→ Module:WikidataIB第759行Lua錯誤:attempt to index field 'wikibase' (a nil value){{Ifnoteq then show|{{#invoke:WikidataIB |getValue |P17 |qid=Q60 |fwd=ALL |osd=no |rank=best |noicon=true}}|United States|USA}}→ Module:WikidataIB第759行Lua錯誤:attempt to index field 'wikibase' (a nil value)