Difference between revisions of "Template:Emptyor"
imported>Pppery (Restore my version using Template:MultiReplace instead of a function in [[Module:WikidataIB]; it is not "less klunky" or "more flexible" to pass the list of replacements to a template instead of putting them in a module with separate string:gsub calls) |
imported>RexxS (Undid revision 818979692 by Pppery (talk) fails to properly deal with all the cases that this version covers. This version is simpler, cleaner and has worked since its creation.) |
||
| Line 1: | Line 1: | ||
| − | {{ | + | {{#invoke:WikidataIB |emptyor |{{{1|}}}}}<noinclude> |
{{documentation}}</noinclude> | {{documentation}}</noinclude> | ||
Latest revision as of 21:30, 6 January 2018
| This template uses Lua: |
Description
Emptyor tests a piece of text to ascertain whether it's effectively empty or contains some text. It is a wrapper for the function emptyor() in Module:WikidataIB.
If the unnamed parameter consists only of html tags, punctuation (e.g. Wiki-markup) and whitespace, then Emptyor returns nothing; otherwise it returns the parameter unchanged.
In designing a Wikidata-enabled infobox, we may need to apply markup, such as italics, to a value fetched from Wikidata. However, if that value is blank, then the markup would normally produce a label with a blank entry for its data. Using this template will suppress such rows when nothing is returned from Wikidata.
Usage
Example:
label99 = This Field
data99 =
{{emptyor
| <i>{{#invoke:WikidataIB |getValue |P666 |name=thisfield |qid={{{qid|}}} |suppressfields={{{suppressfields|}}} |fetchwikidata={{{fetchwikidata|}}} |onlysourced={{{onlysourced|}}} |noicon={{{noicon|}}} |list={{{list|}}} | {{{thisfield|}}} }}</i>
}}
If the getValue call returns anything, the infobox will show a row labelled "This field", with the value returned in italics.
If the getValue call returns nothing, the infobox will not show the row "This field".
| The above documentation is transcluded from Template:Emptyor/doc. (edit | history) Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages. Please add categories to the /doc subpage. Subpages of this template. |