[htmltmpl] The snarkiest way to print out specific values of a hash using HTML::Template?
Brought to you by:
samtregar
From: Justin S. <ju...@sk...> - 2005-02-17 05:06:32
|
Hello all, Been looking for a while for this answer, and seem to think it must have been asked before, although both the archives mentioned in the docs are down. So here goes: Is there an easy way to pass a Hash to HTML::Template in hopes to use the key/value pairs, without putting it in a <TMPL_LOOP>? Along with HTML::Template, I'm also familiar with Template-Toolkit. It had the dot syntax, where you can navigate a complex data structure like - $this->{that}->{then}->{some} like this: [% this.that.then.some %] I can't find anything similar in HTML::Template, except to put a <TMPL_LOOP> around the block of HTML when I want to access a value in a hash. I guess this is fine with me - as long as performance isn't completely dismal; To clarify, in my Perl code, I have a hash that holds any errors that may have been put forth from an HTML form. Something like: my %errors = (forgot_name => 1, impossible_zipcode => 1, is_the_unabomber => 0); my theoretically HTML would be something like: <TMPL_IF EXPR="errors.forgot_name == 1"> <p>You forgot your name!</p> </TMPL_IF> Thanks for your time! justinSimoni.Artist -- .: art http://justinsimoni.com .: phone 720 436 7701 |