Difference between revisions of "Template:Ifndef"

From Sumo
Jump to navigation Jump to search
(Template that helps for branches since Sourceforge has no #if:)
 
(Added documentation)
 
Line 1: Line 1:
{{{2{{{1|}}}|}}}
+
{{{2{{{1|}}}|}}}<noinclude>
 +
== Description ==
 +
 
 +
<pre>
 +
{{Ifndef|{{{p}}}|then}}
 +
</pre>
 +
 
 +
Allows conditional code for optional parameters. If the parameter <code>p</code> is undefined, the string <code>then</code> is inserted. The template is the opposite of [[Template:Ifdef]]. It is necessary, because the MediaWiki of Sourceforge here has not got the extended parser function like <code>#if:</code>. For further details, look at the Wikipedia pages [http://meta.wikimedia.org/wiki/Template:Ifndef Template:Ifndef] and [http://meta.wikimedia.org/wiki/Help:Advanced_templates#Branching_techniques_without_ParserFunctions Help:Advanced templates#Branching techniques without ParserFunctions].
 +
 
 +
== Example ==
 +
 
 +
<pre>
 +
{{ifndef|{{{url}}}|
 +
{{!}}-
 +
{{!}} colspan{{=}}"2" {{!}} Please help to find a URL }}
 +
</pre>
 +
 
 +
If the parameter <code>url</code> is defined, the code results in nothing. If it is undefined,
 +
 
 +
<pre>
 +
|-
 +
| colspan="2" | Please help to find a URL
 +
</pre>
 +
 
 +
is inserted.
 +
</noinclude>

Latest revision as of 09:12, 9 February 2011

Description

{{Ifndef|{{{p}}}|then}}

Allows conditional code for optional parameters. If the parameter p is undefined, the string then is inserted. The template is the opposite of Template:Ifdef. It is necessary, because the MediaWiki of Sourceforge here has not got the extended parser function like #if:. For further details, look at the Wikipedia pages Template:Ifndef and Help:Advanced templates#Branching techniques without ParserFunctions.

Example

{{ifndef|{{{url}}}|
{{!}}-
{{!}} colspan{{=}}"2" {{!}} Please help to find a URL }}

If the parameter url is defined, the code results in nothing. If it is undefined,

|-
| colspan="2" | Please help to find a URL

is inserted.