[Templates] Getting keys from a hash
Mark Mills
extremely at hostile.org
Tue Feb 26 15:11:11 GMT 2008
Maybe, rather than rolling your own hookup to CGI, you should look at
the CGI plugin for TT:
http://template-toolkit.org/docs/modules/Template/Plugin/CGI.html
It has code to avoid the exact issue you ran into. One extra method that
does what you need.
METHODS
<#>
In addition to all the methods supported by the |CGI| module, this
plugin defines the following.
params()
<#>
This method returns a reference to a hash of all the |CGI|
parameters. Any parameters that have multiple values will be
returned as lists.
[% USE CGI('user=abw&item=foo&item=bar') %]
[% CGI.params.user %] # abw
[% CGI.params.item.join(', ') %] # foo, bar
Karl Dane wrote:
> No wonder I came a cropper!
>
> I'd kinda ignored the CGI aspect, as usually if you've got something
> more than just a plain and simple data structure it shows up as such in
> Data::Dumper. Since it looked like a plain old hash, I treated it as a
> plain old hash.
>
> Thanks again, everyone!
>
> Karl
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.template-toolkit.org/pipermail/templates/attachments/20080226/218d4303/attachment.htm
More information about the templates
mailing list