User:Kylu/qif

From Wikipedia, the free encyclopedia

Contents

[edit] {{qif}} Logical Structure

Note: #comments are for my personal review only.

Please don't try to make this template work, especially
not with #comments in them!
I'm just trying to make sense of a bit of esoteric template magic.
Please feel free to ignore this page. It's not representitive of
anything worth anything.
Note: if {{qif}} is depreciated/orphaned, I would appreciate it if
this page were not modified. Please, just let it break instead.
More fun! Category:Esoteric templates
Also, don't forget to check Locke's expansion on the discussion page!

[edit] Unexpanded (Original)

{{{else{{{test|}}}|{{{test{{{test|}}}|{{{then|}}}}}}}}}

[edit] Expanded (Probably nonsensical)

{
 {
  {else           #`test` is empty, parse next arg[2].
   {
    {
     {test|}      #[2]this one.
    }
   }|{
    {
     {test        #determine/parse `test`
      {
       {
        {test|}   #`test`
       }
      }|{
       {
        {then|}   #`test` is not empty, parse argument[1] (same line)
       }
      }
     }
    }
   }
  }
 }
}

q.v.: {{booleq}} and {{boolne}} (Boolean equality tests)

[edit] Usage (from Template Talk:Qif)

{{qif
  |test=VARIABLE_OR_PARAMETER_TO_TEST
  |then=code if 'test' is not empty
  |else=code if 'test' is empty
}}

Parameter else is optional. So you may also do:

{{qif
  |test=VARIABLE_OR_PARAMETER_TO_TEST
  |then=code if 'test' is not empty
}}

[edit] Example (from Template Talk:Qif)

Code Result
{{qif
  |test={{boolne|foo|bar}}
  |then=true
  |else=false
}}

true

{{qif
  |test={{booleq|foo|bar}}
  |then=true
  |else=false
}}

false

{{qif
  |test=
  |then=bar
}}
{{qif
  |test=foo
  |then=bar
}}

bar