Difference between revisions of "Template:If then wikilink/doc"

From blackwiki
Jump to navigation Jump to search
imported>Hike395
(document "after" parameter)
imported>Hike395
(update doc)
 
Line 7: Line 7:
 
The {{para|after}} parameter is emitted immediately after the wikilink. This is useful, e.g., for tracking categories.
 
The {{para|after}} parameter is emitted immediately after the wikilink. This is useful, e.g., for tracking categories.
  
== Example ==
+
The {{para|linktext}} parameter allows the link text of the wikilink to be overridden. Otherwise, it will be the same as the first positional argument.
 +
 
 +
== Examples ==
 
* <code><nowiki>{{If then wikilink |{{#invoke:WikidataIB |getSiteLink |wiki=enwikisource |qid=Q56862211}} | prefix=s:en:|after=!}}</nowiki></code> → {{If then wikilink |{{#invoke:WikidataIB |getSiteLink |wiki=enwikisource |qid=Q56862211}} | prefix=s:en: | after=!}}
 
* <code><nowiki>{{If then wikilink |{{#invoke:WikidataIB |getSiteLink |wiki=enwikisource |qid=Q56862211}} | prefix=s:en:|after=!}}</nowiki></code> → {{If then wikilink |{{#invoke:WikidataIB |getSiteLink |wiki=enwikisource |qid=Q56862211}} | prefix=s:en: | after=!}}
 +
* <code><nowiki>{{If then wikilink |{{#invoke:WikidataIB |getSiteLink |wiki=enwikisource |qid=Q56862211}} | prefix=s:en:|linktext=Wikisource}}</nowiki></code> → {{If then wikilink |{{#invoke:WikidataIB |getSiteLink |wiki=enwikisource |qid=Q56862211}} | prefix=s:en: | linktext=Wikisource}}
  
 
<includeonly>{{sandbox other||
 
<includeonly>{{sandbox other||

Latest revision as of 20:50, 5 January 2020

If the first unnamed parameter is not an empty string, the template returns it as a piped wiki-link using the |prefix= as a namespace or interwiki prefix. Otherwise it returns the second unnamed parameter.

This is only 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 and reduces the calls to a module.

The |after= parameter is emitted immediately after the wikilink. This is useful, e.g., for tracking categories.

The |linktext= parameter allows the link text of the wikilink to be overridden. Otherwise, it will be the same as the first positional argument.

Examples

  • {{If then wikilink |{{#invoke:WikidataIB |getSiteLink |wiki=enwikisource |qid=Q56862211}} | prefix=s:en:|after=!}} → [[s:en:Lua error in Module:WikidataIB at line 480: attempt to index field 'wikibase' (a nil value). |Lua error in Module:WikidataIB at line 480: attempt to index field 'wikibase' (a nil value).]]!
  • {{If then wikilink |{{#invoke:WikidataIB |getSiteLink |wiki=enwikisource |qid=Q56862211}} | prefix=s:en:|linktext=Wikisource}} → [[s:en:Lua error in Module:WikidataIB at line 480: attempt to index field 'wikibase' (a nil value). |Wikisource]]