Difference between revisions of "Template:Ifdef"

From Sumo
Jump to navigation Jump to search
(Template that helps for branches since Sourceforge has no #if:)
 
(Description: Link to opposite Template:Ifndef)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{{1{{{1|}}}|{{{2|}}}}}}
+
{{{1{{{1|}}}|{{{2|}}}}}}<noinclude>
 +
== Description ==
 +
 
 +
<pre>
 +
{{Ifdef|{{{p}}}|then}}
 +
</pre>
 +
 
 +
Allows conditional code for optional parameters. If the parameter <code>p</code> is defined, the string <code>then</code> is inserted. The template is the opposite of [[Template:Ifndef]]. 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:Ifdef Template:Ifdef] and [http://meta.wikimedia.org/wiki/Help:Advanced_templates#Branching_techniques_without_ParserFunctions Help:Advanced templates#Branching techniques without ParserFunctions].
 +
 
 +
== Example ==
 +
 
 +
<pre>
 +
{{ifdef|{{{url}}}|
 +
{{!}}-
 +
{{!}} colspan{{=}}"2" {{!}} {{{url}}} }}
 +
</pre>
 +
 
 +
If the parameter <code>url</code> is defined, the code results in
 +
 
 +
<pre>
 +
|-
 +
| colspan="2" | http://a.url
 +
</pre>
 +
 
 +
If it is not defined, the code results in nothing.
 +
</noinclude>

Latest revision as of 09:09, 9 February 2011

Description

{{Ifdef|{{{p}}}|then}}

Allows conditional code for optional parameters. If the parameter p is defined, the string then is inserted. The template is the opposite of Template:Ifndef. 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:Ifdef and Help:Advanced templates#Branching techniques without ParserFunctions.

Example

{{ifdef|{{{url}}}|
{{!}}-
{{!}} colspan{{=}}"2" {{!}} {{{url}}} }}

If the parameter url is defined, the code results in

|-
| colspan="2" | http://a.url

If it is not defined, the code results in nothing.