I have an array of data I want to output as a UL using PHPTAL (easy) with class attributes supplied by the array (easy), a class attribute for first and for the last element (easy)... all at the same time (hard).
Ie. I want to combine:
<ul tal:repeat="item items">
<li class="${item/class}">${item/text}</li>
</ul>
with this
<ul tal:repeat="item items">
<li tal:attributes="class repeat/item/first 'first'">${item/text}</li>
</ul>
and this
<ul tal:repeat="item items">
<li tal:attributes="class repeat/item/last 'last'">${item/text}</li>
</ul>
This is purely presentational stuff, so I'd rather do it purely in PHPTAL. Is this possible? How?
No, there's no pure TALES for this.
<li tal:attributes="class php:repeat.item.last ? 'last'
: (repeat.item.first ? 'first' : NULL)">