Difference between revisions of "Template:If then show/doc"
Jump to navigation
Jump to search
imported>RexxS (→Prefix and suffix: a little wider) |
imported>RexxS (clearer) |
||
Line 1: | Line 1: | ||
{{Documentation subpage}} | {{Documentation subpage}} | ||
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> | <!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> | ||
− | This template tests whether the first unnamed parameter is not an empty string and returns it if it | + | This template tests whether the first unnamed parameter is not an empty string and returns it if it is not empty. Otherwise it returns the second unnamed parameter. |
This is useful when the first parameter is a <nowiki>{{#invoke: }}</nowiki> of a Lua module that may return a value or nothing. Because it uses the <nowiki>{{#invoke: }}</nowiki> just once, it simplifies the coding of infoboxes, for example. | This is useful when the first parameter is a <nowiki>{{#invoke: }}</nowiki> of a Lua module that may return a value or nothing. Because it uses the <nowiki>{{#invoke: }}</nowiki> just once, it simplifies the coding of infoboxes, for example. |
Revision as of 17:14, 23 January 2019
![]() | This is a documentation subpage for Template:If 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 not an empty string and returns it if it is not empty. Otherwise it returns the second unnamed parameter.
This is useful when the first parameter is a {{#invoke: }} of a Lua module that may return a value or nothing. Because it uses the {{#invoke: }} just once, it simplifies the coding of infoboxes, for example.
The optional third and fourth unnamed parameters provide a prefix and a suffix for the first parameter when returned. This enables the designer to construct more complex templates that still only use one invoke of a Lua module.
Usage
- Lua error in Module:Wd at line 196: attempt to index field 'wikibase' (a nil value). (P26) for Lua error in Module:Wd at line 196: attempt to index field 'wikibase' (a nil value). (Q151973)
{{If then show|{{#invoke:WikidataIB|getValue|P26|qid=Q151973|fwd=ALL|osd=no}}|unmarried}}
→ unmarried
- Lua error in Module:Wd at line 196: attempt to index field 'wikibase' (a nil value). (P26) for Lua error in Module:Wd at line 196: attempt to index field 'wikibase' (a nil value). (Q905)
{{If then show|{{#invoke:WikidataIB|getValue|P26|qid=Q905|fwd=ALL|osd=no}}|unmarried}}
→ unmarried
Prefix and suffix
A table can be designed to display a row only when a particular property of the article exists on Wikidata.
- Lua error in Module:Wd at line 196: attempt to index field 'wikibase' (a nil value). (P26) for Lua error in Module:Wd at line 196: attempt to index field 'wikibase' (a nil value). (Q151973)
{| class="wikitable" |- ! scope="col" style="width:15em;" | Label ! scope="col" style="width:36em;" | Value {{If then show|{{#invoke:WikidataIB|getValue|P26|qid=Q151973|fwd=ALL|osd=no}}||<tr><th>{{#invoke:WikidataIB|getLabel|P26|qid=Q151973}}</th><td>|</td></tr>}} |}
- →
Label | Value |
---|
- Lua error in Module:Wd at line 196: attempt to index field 'wikibase' (a nil value). (P26) for Lua error in Module:Wd at line 196: attempt to index field 'wikibase' (a nil value). (Q905)
{| class="wikitable" |- ! scope="col" style="width:15em;" | Label ! scope="col" style="width:36em;" | Value {{If then show|{{#invoke:WikidataIB|getValue|P26|qid=Q905|fwd=ALL|osd=no}}||<tr><th>{{#invoke:WikidataIB|getLabel|P26|qid=Q905}}</th><td>|</td></tr>}} |}
- →
Label | Value |
---|