On 29-10-2010 at 08:23:42 GRolf <ger...@pictureparking.com> wrote:

I often find myself using tal:repeat to implode an array

in php
$myarr = array('one', 'two', 'three');

is easily converted to
one, two, three

implode(', ',$myarr);

But in PHPTal, this is quite cumbersome

<span tal:repeat="val myarr">
${val}<span tal:condition="not:repeat/val/end">, </span>

Isn't there an easier solution?

You could write TALES modifier:


function phptal_tales_comma($expr,$nothrow)
return '('.phptal_tale('not:repeat/'.$expr.'/end',$nothrow).'? : ", " : "")';

regards, Kornel

PHPTAL mailing list

Reply via email to