in reply to Re: Template Toolkit - passing hashes
in thread Template Toolkit - passing hashes
(just to recap) If you already know the key, you can use it directly too with [% thing.hashkey %]
like this:
use Template; my $data = { user => { nick => f00li5h, home => '/home/f00li5h', bio => '/home/f00li5h/.plan', }, page_title => 'user profile' }; my $template = q{ <html><head><title>[% page_title || 'lovely' %]</title></head> <body> about user [% user.nick %] <hr> likes to spend lots of time in or arround [% user.home %] you can read more about [% user.nick %] at [% user.bio %] </body> </html> }; my $TT = Template->new(); $TT->process(\$template , $data );
which gives you something a little like this:
<html><head><title>user profile</title></head> <body> about user f00li5h <hr> likes to spend lots of time in or arround /home/f00li5h you can read more about f00li5h at /home/f00li5h/.plan </body> </html>
|
|---|