phpphptaltemplate-tal

Tal condition, defining multiple conditions within same line


Is there an alternative to what I do below :

...
<div class="abc" tal:condition="this/condition1">
    <div class="abc2" tal:condition="this/condition2">
    ...
    </div>
</div>
...

Such as :

...
<div class="abc" tal:condition="this/condition1 AND this/condition2">
...
</div>
...

Solution

  • It's a bit silly, but there's no logical AND in TALES.

    You can use php: prefix:

    <div tal:condition="php:this.condition1 AND this['condition2']">
    

    but keep in mind that with php: you need to use type-dependent syntax (. for objects, [] for arrays, because / becomes division).