[Templates] Getting keys from a hash

Karl Dane karl at rince.net
Tue Feb 26 10:22:02 GMT 2008


This should be stunningly easy, but for some reason the 'keys' VMethod 
is giving me nothing.

My template:
---
should tell me this is a hash:
[% cgihash %]

dump out the contents of the hash:
[% USE Dumper %]
[% Dumper.dump(cgihash) %]

Now give me the keys:
[% cgihash.keys %]

[[ TEMPLATE ENDS ]]

---
Output:

   should tell me this is a hash:
HASH(0x88303dc)

dump out the contents of the hash:

$VAR1 = {
           'a' => 'newentry',
           'newbooking' => '1',
           'day' => '06',
           'monthdigit' => '02',
           'year' => '2008',
           'room' => '9',
           'gender' => 'male',
           'beds' => '3',
           'nights' => '2',
           'submit' => 'Book'
         };


Now give me the keys:


[[ TEMPLATE ENDS ]]


Also no joy with cgihash.sort or cgihash.list('keys').

Can someone please tell me what I'm doing wrong?

Thanks!

Karl



More information about the templates mailing list