RE: [Templates] hash.keys not working on blessed hash?

[prev] [thread] [next] [Date index for 2004/12/15]

From: Thomas, Mark - BLS CTR
Subject: RE: [Templates] hash.keys not working on blessed hash?
Date: 17:06 on 15 Dec 2004
> 
> yes, have the class implement this method:
> 
> sub keys {
>   my $self = shift;
>   return [ keys %$self ];
> }

I was hoping to find a way that didn't require modifying classes. I have a
template which can be pointed at any TT source to find out what variables
are available (like a fancy Dumper output). However it descends into a hash
only if hash.keys exists.

I found this out recently when I set up Bryar and wanted to find out what
variables I could use in my custom templates. My introspection template
would work for much of the data structure but skip the various Bryar objects
embedded in the data structure. Yet they can be accessed like normal hashes:
[% bryar.config.description %].

There seems to be a mismatch between what can be accessed as keys and what
the keys vmethod returns.

- Mark.


_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] hash.keys not working on blessed hash?
Thomas, Mark - BLS CTR 13:57 on 15 Dec 2004

RE: [Templates] hash.keys not working on blessed hash?
Thomas, Mark - BLS CTR 17:06 on 15 Dec 2004

Generated at 08:56 on 15 Mar 2005 by mariachi v0.52