Am trying to get some Perl code into a template (to do with presentation ;)
) 

How can I do the following in TT without using a FOREACH? Just pointing me
to the right place in the docs would be great. Sadly, TT doesn't have map
(or at least I can't find it in vmethods etc.)

Perl
$result = join( ',',  map{ $my_hash->{A_KEY}->{$_} }
                               grep{ ! /some_string/ }
                               sort keys %{$my_hash->{A_KEY}}
                         ); 

Templates are for data presentation, not for programming! ;)
 
 
There's no way to do "map" in pure TT syntax - so you have to choose:
 
1) Prepare and filter your data in perl code (data source, etc) and then
pass it to template
 
2) Use FOREACH with NEXT UNLESS key.match('some_string')
 
3) Write TT plugin for your needs and [% USE %] it in template
 
4) Embed perl code in TT using [% PERL %] block

--
Sergey Martynoff


_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to