[PHPTAL] Generating multiple values for the class attribute dynamically

romtek romtek at gmail.com
Tue Oct 5 10:53:40 CEST 2010


2010/10/4 Kornel Lesiński <kornel at aardvarkmedia.co.uk>

>
> On 2 Oct 2010, at 07:15, romtek wrote:
>
> > Hi,
> >
> > I sometimes need to use multiple values for the class attribute but can't
> seem to find a way to do this in PHPTAL if those values are to be determined
> at run-time. For example,
> >
> > <tr tal:attributes="class php:item.isParent() ? 'parent' : null">...</tr>
> > I also need to set an additional class value, say:
> > "class php:item.is_inactive ? 'inactive' : null"
> >
> > Would somebody please suggest a way to do this?
>
> If you don't mind getting class=" " sometimes (harmless in HTML), then you
> can simply use:
>
> <tr class="${php:…} ${php:…}">
>

I don't mind that at all. This works. Thank you very much! I don't need to
resort to an unpleasant hack anymore.

However, that it works has surprised me as I've never used php: tale inside
${}. I think it's worth mentioning this in the manual.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.motion-twin.com/pipermail/phptal/attachments/20101005/fe6e6a26/attachment.htm


More information about the PHPTAL mailing list