Not sure if TT has something about it, but it's very easy to add it
yourself, e.g.:
new Template(... VARIABLES => { ref => sub { ref(@_) } ... )
[% IF ref(structure) == 'ARRAY' %]
.. do FOREACH
[% END %]
-M.
On Wed, 2007-10-03 at 15:43 -0400, Ronald J Kimball wrote:
> Is it possible to determine the type of a variable in TT?
>
>
> For example, give the following data:
>
> $structure = [ 1, 2, [3, 4], 5, [6], 7];
>
> While iterating over that structure in TT, how could I tell whether each
> item is a scalar or a list?
>
> [% FOREACH item IN structure %]
> [% IF ??? %]
> It's a scalar!
> [% ELSE %]
> It's a list!
> [% END %]
>
>
> (What I'm trying to do is create a block to traverse the structure
> recursively.)
>
>
> thanks,
> Ronald
>
> _______________________________________________
> templates mailing list
> [email protected]
> http://lists.template-toolkit.org/mailman/listinfo/templates
>
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates