1 <:if:>, <:elif:>, <:else:>

<:if expr:>
   [ <:elif expr:> ]
   [ <:else:> ]
<:/if:>

If the Python expression expr evaluates to true, render until an <:/if:>, <:else:> or <:elif:> tag is encountered. The expr arguments in <:if:> and <:elif:> tags must be enclosed in backticks, of course.

If it finds an <:elif:> tag and nothing has yet been rendered within this <:if:> block and expr evaluates to true, renders until it runs into another <:elif:>, <:else:> or <:/if:> tag. If an <:else:> is encountered and nothing has yet been rendered in this <:if:> block, renders until it hits the <:/if:>, <:elif:> or another <:else:> (if you put an <:else:> before an <:elif:> or another <:else:>, which while syntactically valid, is erroneous since the contents following the <:elif:> or <:else:> will never be rendered).

This is just a fancy way of saying that these tags work just like if, elif, and else in Python.

Using <:elif:> outside of an <:if:> block will raise an error. Using <:else:> outside of an <:if:>, <:try:> or <:for:> block will also raise an error.

In the following example, the output will be Shaft is the Man.

<:set myVar `1`:>
<:if `myVar > 0`:>
    Shaft is
    <:if `myVar == 6`:>
    the black private dick.
    <:elif `myVar == 4`:>
    a sex machine with all the chicks.
    <:else:>
    the Man.
    <:/if:>
<:else:>
    Why is myVar not greater than 0?
<:/if:>