Template talk:Ifndef

From Wikipedia, the free encyclopedia

Contents

[edit] Documentation

{{ifndef}} is a compact variant of {{Qif}} for simple "if defined then void else do" statements with blank then part. It's the opposite of {{ifdef}}.

[edit] Usage

{{Ifndef|value|result}} yields result  if value  is blank.

This simple template cannot be substituted, it's used to simplify the following equivalent but somewhat cryptic (names don't matter) code variants:

{{{2{{{1|}}}|}}}
{{{result{{{value|}}}|}}}
{{{then{{{test|}}}|}}}


[edit] Example

Code Result
1 {{Ifndef| |empty}} 1 empty
2 {{Ifndef|x|gotcha}} 2
3 {{Ifndef| {{{1| }}} | {{{1| }}} undefined}} 3 undefined
4 {{Ifndef| {{{1  }}} | {{{1  }}} bad idea}} 4
5 {{Ifndef| {{ns:0}} | main namespace}} 5 main namespace
6 {{Ifndef||compare {{Tlx|ifdef}} }} 6 compare {{ifdef}}
7 {{Ifndef|| 2=see=[[#Caveats]] }} 7 see=#Caveats
8 {{Ifndef|| see=[[#Caveats]] }} 8

Unlike ifdef the minimalistic ifndef cannot reject a missing second parameter.

[edit] Caveats

In templates the characters "=" (=) and "|" (|) cannot be used as is in parameters. The numeric character references = and | are often good enough, but for Wiki and XHTML markup the literal characters are required:

  1. For | Template:! (edit talk links history) offers a workaround.
  2. For = the template parameter mechanism allows {{ifndef| |2=ok=yes}} resulting in "ok=yes" instead of {{ifndef| |bad=idea}} resulting in "".

Substitution works only for {{ifdef}}, but not for {{ifndef}} or {{qif}}.

[edit] See also

[edit] Discussion

Add issues below as you see fit, sign with ~~~~

TFD nomination of Template:Ifdef
Template:Ifdef has been nominated for deletion. You are invited to comment on the discussion at the template's entry on the Templates for Deletion page. Thank you.
DRV of Template:Ifdef
Template:Ifdef is now under deletion review. The #if: oddity and other issues are now documented on Meta.