Prev |  | Next

### `tal:condition`

The element and its content will be shown only if the condition is evaluated to true.

                <p tal:condition="identified"> Welcome member … </p>

                <p tal:condition="not: identified">
      Please login before accessing this page
    </p>

If the PHP backend does not provide your templates with enough methods, you will often have to fall back to PHP for special conditions:

                <span tal:comment="show only if more than five items in the cart" tal:condition="php: cart.countItems() GT 5">…</span>

This may put too much logic inside the template and it is sometimes preferable to provide boolean attributes or accessible methods to the template:

                <span tal:condition="cart/hasEnoughItems">…</span>

Prev | Up | Next
`tal:define` | Home | `tal:repeat`