[PHPTAL] Imploding tal:attributesfrom source array
Anton Andrievskij
x.meglio at gmail.com
Tue Jan 29 06:53:44 CET 2008
In your PHP:
*$imgAttr = '';
foreach($attributes as $attrname => $attrvalue)
$imgAttr .= "$attrname $attrvalue;";
$templateObject->imgAttr = $imgAttr;*
In your template:
*<img tal:attributes="${imgAttr}" />*
Hope this may help.
Anton Andryevskyy
On Jan 29, 2008 12:30 AM, Werner <lists at mollentze.co.za> wrote:
> Hi!
>
> Has anyone found an easy (and readable) way to do the following by using
> tal:attributes ?
>
> 1) You have an $attributes array in php:
> $attributes = array('id' => 'some_id', 'class' => 'some_class',
> 'src' => 'img/beautiful.jpg');
>
> 2) You want to apply all the attributes as an element's attributes:
> <img id="some_id" class="some_class" src="img/beautiful.jpg"/>
>
> Kind Regards,
> Werner
>
>
> _______________________________________________
> PHPTAL mailing list
> PHPTAL at lists.motion-twin.com
> http://lists.motion-twin.com/mailman/listinfo/phptal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.motion-twin.com/pipermail/phptal/attachments/20080129/dafec7a9/attachment.htm
More information about the PHPTAL
mailing list