Ok, here you are.
use MIME::Lite::TT::HTML;
my $HoH = {
item_hoh => {
row1 => { index => 99, col1 => "Col 1", col2 => "Col 2" },
row2 => { index => 42, col1 => "Col 1", col2 => "Col 2" },
}
};
my $msg = MIME::Lite::TT::HTML -> new(
From => 'donotreply@windowsintowaukesha.com',
To => 'you@foo.bar',
Subject => 'Bid Strategy System - Final Pricing Approval',
Template => {
html => 'email_bid_strategy_final_appr.tt',
},
TmplParams => $HoH,
);
where email_bid_strategy_final_appr.tt is
[% FOREACH record IN item_hoh.values.nsort('index') %]
<tr>
<td>[% record.index %]</td>
<td>[% record.col1 %]</td>
<td>[% record.col2 %]</td>
</tr>
[% END %]
To show that the correct output is produced, I've added a line to print out $html in the module's code:
...
$tt->process( $template->{html}, $tmpl_params, \$html ) or croak $
+tt->error;
print STDERR $html; # <---
...
and the output is (as expected):
<tr>
<td>42</td>
<td>Col 1</td>
<td>Col 2</td>
</tr>
<tr>
<td>99</td>
<td>Col 1</td>
<td>Col 2</td>
</tr>
Now where's my lunch? ;)
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.