[Templates] Getting keys from a hash
Clinton Gormley
clint at traveljury.com
Tue Feb 26 11:06:31 GMT 2008
On Tue, 2008-02-26 at 11:00 +0000, Karl Dane wrote:
> I guess my example wasn't a very good one - I just wanted to demonstrate
> that I was getting _nothing_ when using the keys method. If it had
> worked as expected, then it should have returned something like
> 'ARRAY(0x8a8ca58)'
... which is what I get when I try it on my system, with this code:
[%
cgihash = {
'a' => 'newentry',
'newbooking' => '1',
'day' => '06',
'monthdigit' => '02',
'year' => '2008',
'room' => '9',
'gender' => 'male',
'beds' => '3',
'nights' => '2',
'submit' => 'Book'
};
%]
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(0x287c4a0)
dump out the contents of the hash:
$VAR1 = {
'monthdigit' => '02',
'a' => 'newentry',
'nights' => '2',
'submit' => 'Book',
'room' => '9',
'newbooking' => '1',
'beds' => '3',
'day' => '06',
'year' => '2008',
'gender' => 'male'
};
Now give me the keys:
ARRAY(0x28c7170)
[[ TEMPLATE ENDS ]]
More information about the templates
mailing list