Cees Hek wrote:
> Check the Template::Manual::VMethods docs and search for the 
> 'list' method:
> 
> list
>            Return the value as a single element list.  This can be
> useful if you have a variable which may contain a single item or a
> list and you want to treat them equally.  The 'list' method can be
> called against a list reference and will simply return the original
> reference, effectively a no-op.
> 
>                [% thing.list.size %]  # thing can be a scalar 
> or a list

Indeed. But I ran into the problem of "thing" being a hashref, or even
worse a blessed reference. Adding a "list" vmeth for the hashref would
certainly have been trivial, but that didn't cover the blessed ref
issue; that's why I needed a function (which, as noted previously on
this thread, has definite limitations.)

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

Reply via email to