Use of these tags parallels the if/elif/else keywords in Python.
The <al-if> tag is a content enclosing tag while <al-elif> and <al-else> are empty tags that control the behaviour of the enclosing <al-if> tag. Use the expr attribute of the <al-if> and <al-elif> tags to specify a test expression.
If the expression in the expr attribute of the
<al-if> tag evaluates TRUE
then the enclosed content
up to either the next <al-elif> or <al-else> tag
will be sent to the output. If the expression evaluates
FALSE
then the expression in the next <al-elif> (if
any) is tested. If that expression is TRUE
then the content
controlled by that tag is included. Any number of cascading
<al-elif> tags can be used.
If the expression in the expr attribute of the
<al-if> tag and all preceding <al-elif> tags
evaluate FALSE
then content between an <al-else>
tag (if any) and the closing </al-if> tag will written to the
output.
For example:
>>> import albatross >>> ctx = albatross.SimpleContext('.') >>> albatross.Template(ctx, '<magic>', ''' ... <al-if expr="15 < 10"> ... 15 is < 10 ... <al-elif expr="15 < 20"> ... 15 is >= 10 and < 20 ... <al-else> ... 15 is >= 20 ... </al-if> ... ''').to_html(ctx) >>> ctx.flush_content() 15 is >= 10 and < 20