doubletb has asked for the wisdom of the Perl Monks concerning the following question:
I have a PERL script that successfully sends PERL messages using MIME::Lite::TT::HTML. However, I'm trying to update the email template to be more dynamic -- I want to include a FOREACH loop that loops through the elements of the hash I pass the template as TmplParams. My problem is that I have no idea what that hash of parameters is called in the template. I understand I can refer to elements of the hash by their keys, but if the keys aren't assigned until runtime, how do I pull them out? Does anyone know? I've tried VARIABLES, TmplParams, a bunch of other random things I've made up... pseudo-code below. I'm looking for what to put in the <???????> to make it work.
SCRIPT: my %emailOptions = { '<random ID>' => { 'queue' = 'Mig', 'priority' = 'high'}, '<random ID 2>' => { 'queue' = 'Inf', 'priority' = 'high'}, '<random ID 3>'=> { 'queue' = 'Mig', 'priority' = 'low'} }; my (%options); $options{INCLUDE_PATH} = '/www/some/where/' my $msg = MIME::Lite::TT::HTML->new( From => someone@somewhere.com , To => someone@elsewhere.com, Subject => 'Neglected Tickets', Template => { ABSOLUTE => 1, html => /path/to/TEMPLATE}, TmplOptions => \%options, TmplParams => \%emailOptions, 'X-MSMail-Priority' => 'High' ); TEMPLATE: <table> <tr> <td><b>ID</b></td> <td><b>Queue</b></td> <td><b>Priority</b></td> </tr> <tr> [% FOREACH ticket IN <??????> %] <td>[% <key> %]</td> <td>[% ticket.queue %]</td> <td>[% ticket.priority %]</td> [% END %] </tr> <table>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Mime::Lite::TT::HTML Input Hash Name?
by keszler (Priest) on Oct 04, 2011 at 14:43 UTC | |
by doubletb (Initiate) on Oct 04, 2011 at 15:15 UTC | |
|
Re: Mime::Lite::TT::HTML Input Hash Name?
by Anonymous Monk on Oct 05, 2011 at 00:20 UTC |