Kornel Lesiński <kor...@...> writes:

> 
> On 08-01-2009 at 21:47:29 Trent Moyer <tmo...@...> wrote:
> 
> > <tr tal:repeat="item list" tal:attributes="class alt:repeat/item/odd |  
> > nothing">
> >   ... HTML Code ...
> > </tr>
> >
> > The intent is to make every other row have a class="alt".
> >
> > This is my code for the modifier:
> >
> > function phptal_tales_alt( $src, $nothrow )
> > {
> >     $src = trim($src);
> >     return '( '.phptal_tales($src, $nothrow)." ? 'alt' : null )";
> > }
> >
> > The problem that I am having is that this modifier and the example  
> > modifier
> > given in the PHPTAL documentation do not work when used with multiple  
> > options (a
> > | b | c). The code returned by phptal_tales_alt() is "( Array ? 'alt' :  
> > null )".
> 
> This is because your modifier gets all code, including "| nothing" part, and
this causes phptal_tales() to
> return array with each part of the expression.
> 
> I've created phptal_tale() function (without 's') that always returns single
expression, but code it
> returns is not very elegant (due to limitations of what constructs can be used
in PHP expression).
> 
> To get it working you can also simply leave out the "| nothing" part.
> 

That is good to know about the phptal_tale() function. Both suggestions solve
the error, but both still leave class="" for every other row. I would like to
drop this attribute entirely.

Is there a function similar to phptal_tales() that only returns the "active",
non-error, item in a sequence like (var/one | var/two | nothing)? I would have
thought that a function like this would be used internally at least.



_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to