Hi,
I am trying to switch from Smarty to phptal. I am enjoying it a lot in
the current project and plan to use it on further developments.
One task always hits me where I end up having to mix the "presentation"
back to my PHP code. But maybe there is a phptal-based solution.
In loops, I want to set different "class" attributes at the same time,
depending on certain criterias, e.g.
<ul>
<li>Regular</li>
<li class="current">Currently selected item</li>
<li class="last">Last item</li>
</ul>
I can have either "last" set, using:
<ul tal:repeat="item items">
<li
tal:content="item.content"
tal:attribute="class php:repeat.item.end ? 'last' : ''"
>Regular</li>
</ul>
Or have my current flag set, using:
<ul tal:repeat="item items">
<li
tal:content="item.content"
tal:attribute="class php:item.isCurrent ? 'current' : ''"
>Regular</li>
</ul>
I could try some nested "?" expressions, but this turns out to be quite
ugly, e.g. if I would have more than 2 classes to set:
<ul tal:repeat="item items">
<li
tal:content="item.content"
tal:attribute="class php:item.isCurrent ? ( repeat.item.end ? 'last
current' : 'current' ) : (repeat.item.end ? 'last' : '')"
>Regular</li>
</ul>
Any other suggestion on how to acchieve this?
Cheers,
Ernesto
_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal