Hi everyone,
I've just joined this list.
Over the last couple of weeks/months I've hacking away at Leon Brocard's
Sparkle webmail project. Currently I'm finish up the implementation of
themes via Template Toolkit. Things have been going well, except I
inadvertedly ran into a problem with reserved words.
Here is the error I get:
file error - parse error: message_headers line 24: unexpected token
('TO')
With a TT template file like that contains this snip:
[% IF env.to %]
<tr>
<td align="right" width="0%"><b>[% acmemail.T.TO
%]:</b></td>
<td nowrap>[% env.to %]</td>
</tr>
[% END %]
After a persual of the documentation, it appears that TO is a reserved
word.
After a persual of the mailing list archives, I came up with:
http://www.template-toolkit.org/pipermail/templates/2000-July/000070.html
Which suggested to replace quote the reserved word like so:
[% acmemail.T.'TO' %]
However, this doesn't work! Below is the perl code that calls the
template, in case something is wrong in that. I hope the solution to
this is simple... Anything else would require require having the change
the key names in T, which contains all the text values for labels, in
order to make it simple to implement multiple languages. Another option
could be to supply a separate key/value pair in the $vars hash, to set
to_label => $self->{T}->{TO}. That would be kludgy and just not feel
"right".
sub html_message_headers($$$$$$) {
my ($self, $env) = @_;
my $config = {
INCLUDE_PATH => $self->{configuration}->{theme_path},
INTERPOLATE => 1, # expand "$var" in plain text
POST_CHOMP => 1, # cleanup whitespace
EVAL_PERL => 1, # evaluate Perl code blocks
};
my $template = Template->new($config);
my $vars = {
acmemail => $self,
env => $env,
};
my $result;
$template->process('message_headers', $vars, \$result) || die
$template->error();
return $result;
}
--
Regards,
Wim Kerkhoff, Software Engineer
Merilus, Inc. -|- http://www.merilus.com
Email: [EMAIL PROTECTED]