Garrett, Philip wrote:
> The code you sent will always return an array, but will only 
> return the first list element instead of all of them.

Sorry, you're right. I copied that code fragment out of an outdated
package, which has since been corrected to more closely resemble your
version (particularly to return "[EMAIL PROTECTED]" instead of merely "shift");

> On second thought, this probably isn't safe at all.  If the function
you
> wrap normally returns a list of arrayrefs, you'll be unable to tell
from
> as_list() whether the one arrayref you've been passed is TT2's
collapsed
> list or the original returned arrayref (if the return value is a list
of
> only one element).

Point well taken. None of the situations where this has been necessary
for us have involved lists of arrayrefs, so we hadn't taken that
prospect into consideration.

> The only reliable way I can see around this is to use a TT2 plugin
module
> for each Perl module where you need to force some context.  

Definitely the best route. My code is admittedly a shortcut to create
the necessary data structure without having to go back and "fix" the
source of the data. Thanks for clarifying that; I wouldn't want anyone
else out there relying on this hack without understanding its
limitations.

I wonder how this issue is addressed in TT3. Andy?

Jason

_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to