[Templates] Getting keys from a hash
Neo [GC]
neo at gothic-chat.de
Tue Feb 26 10:54:48 GMT 2008
Hi,
this may help you:
[% FOR entry IN cgihash %]
key is: [% entry.key %]
value is: [% entry.value %]
[% END %]
Greets,
Thomas Weber / Neo [GC]
Karl Dane schrieb:
> 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
>
> _______________________________________________
> templates mailing list
> templates at template-toolkit.org
> http://mail.template-toolkit.org/mailman/listinfo/templates
>
More information about the templates
mailing list