Template:Ifnoerror then show/doc: Difference between revisions
Template page
More actions
Created page with "{{Documentation subpage}} This template tests whether the first unnamed parameter contains an error message and returns * the value of the first parameter prefixed by the third parameter value, and suffixed by the fourth parameter value, if there is no error; * the value of the second unnamed parameter, if given, or the first parameter value itself, if there is an error. This is useful when the first parameter is an <nowiki>{{#invoke: }}</nowiki> of a Lua module that m..." |
(No difference)
|
Latest revision as of 02:22, 21 February 2025
| This is a documentation subpage for Template:Ifnoerror then show. It may contain usage information, categories and other content that is not part of the original template page. |
This template tests whether the first unnamed parameter contains an error message and returns
- the value of the first parameter prefixed by the third parameter value, and suffixed by the fourth parameter value, if there is no error;
- the value of the second unnamed parameter, if given, or the first parameter value itself, if there is an error.
This is useful when the first parameter is an {{#invoke: }} of a Lua module that may return an error. Because it uses the {{#invoke: }} just once, it simplifies the coding of infoboxes, for example.
It can be used for adding tracking categories in templates, where showing the module's error message is undesirable.
Usage
- {{#invoke:Infobox mapframe|auto}} called with improper coordinates
{{ifnoerror then show |{{#invoke:Infobox mapframe|auto|onByDefault=yes|coordinates=10, 30}} |ERROR|PREFIX|SUFFIX}}→ERROR
- {{#invoke:Infobox mapframe|auto}} call that produces no errors
{{ifnoerror then show |{{#invoke:Infobox mapframe|auto|onByDefault=yes}} |ERROR|PREFIX|SUFFIX}}→PREFIX{{invoke:Infobox mapframe|...}}SUFFIX
See also
- {{Iferror then show}} – similar template with inverted logic