Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:If not given or empty/doc
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
This module's ''check_parameter'' function checks whether a parameter is given, empty, or nonempty in a template call. It is intended to be called from template definitions only, as <syntaxhighlight lang="wikitext">{{#invoke:If not given or empty|check_parameter|parameter name|before|after|when=NG EM NE|notgiven=|empty=|notempty=}}</syntaxhighlight> This is similar to {{tlx|If then show|<nowiki>{{{parameter name|}}}</nowiki>|...|before|after}}, but also checks if the parameter is *present* in the template call. This can be useful in the calls from a template to some existing templates, where the output depends on the three states of a parameter, as it does in {{tl|Location map}} for {{param|caption}}. The values before and after are added only for cases in which {{para|when}} contains the codes NG (for not given), EM (given but empty), NE (given and not empty). == Examples == Template {{tl|Infobox some thing}} has parameter {{param|image}}. When used on a page, the template can be called without the parameter, as in <code><nowiki>{{Infobox some thing|}}</nowiki></code>, or with the parameter, in which case the parameter can have no value (<code><nowiki>{{Infobox some thing|image=}}</nowiki></code>) or some value (<code><nowiki>{{Infobox some thing|image=some value}}</nowiki></code>). This module has different outputs depending on these three cases. <code><nowiki>{{#invoke:If not given or empty|check_parameter|image|before | after|when=EM|notgiven=[[Image:Red pog.svg|30px]]|empty=EMPTY|notempty=[[File:{{{image}}}|30px]]}}</nowiki></code> ;<code><nowiki>{{Infobox some thing|}}</nowiki></code>: final output is the equivalent of <code><nowiki>[[Image:Red pog.svg|30px]]</nowiki></code>. Text <code><nowiki>before</nowiki></code> and <code><nowiki>after</nowiki></code> is not added because <code><nowiki>when</nowiki></code> does not contain NG (for ''not given''). ;<code><nowiki>{{Infobox some thing|image=}}</nowiki></code>: final output is <code><nowiki>before EMPTY after</nowiki></code>. Text <code><nowiki>before</nowiki></code> and <code><nowiki>after</nowiki></code> is added because <code><nowiki>when</nowiki></code> contains EM (for ''empty''). ;<code><nowiki>{{Infobox some thing|image=Green pog.svg}}</nowiki></code>: final output is the equivalent of <code><nowiki>[[File:Green pog.svg|30px]]</nowiki></code>. Text <code><nowiki>before</nowiki></code> and <code><nowiki>after</nowiki></code> is not added because <code><nowiki>when</nowiki></code> does not contain NE (for ''not empty''). <includeonly>{{Sandbox other|| <!-- Categories below this line; interwikis at Wikidata --> [[Category:If-then-else templates]] }}</includeonly><noinclude> [[Category:Module documentation pages]] </noinclude>
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Para
(
edit
)
Template:Param
(
edit
)
Template:Template link
(
edit
)
Template:Template link expanded
(
edit
)
Template:Tl
(
edit
)
Template:Tlx
(
edit
)
Module:Arguments
(
edit
)
Module:If not given or empty
(
edit
)
Module:Template link general
(
edit
)