For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > March 2008 > HTML::Template









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author HTML::Template
Wijnand Nijs

2008-03-05, 7:02 pm

Hello,

I am using HTML::Template to generate interactive pages for my site. Is
it possibel to use this module to generate (from plaintext and html
templates) to the body (as a var $body) of a mail message?

Something like:

# my $Tmpl = HTML::Template->new(filename => 'templates/html.tmpl');
# $Tmpl->param(
# BOUNDERY => $boundary,
# DATE => $Date,
# TITLE => $Title,
# HTML => $Html,
# );
# print $Tmpl->$Body;
||
Thanks and greetings...
Wijnand Nijs
John Bokma

2008-03-05, 7:02 pm

Wijnand Nijs <w.nijs@alf4all.demon.nl> wrote:

> Hello,
>
> I am using HTML::Template to generate interactive pages for my site. Is
> it possibel to use this module to generate (from plaintext and html
> templates) to the body (as a var $body) of a mail message?
>
> Something like:
>
> # my $Tmpl = HTML::Template->new(filename => 'templates/html.tmpl');
> # $Tmpl->param(
> # BOUNDERY => $boundary,


^

> # DATE => $Date,
> # TITLE => $Title,
> # HTML => $Html,
> # );
> # print $Tmpl->$Body;


Yes, the process method can store the output in a scalar as
follows:

my $body = '';
$tt->process( 'templates/html.tmpl', $vars, \$body )
or die 'Template error: ', $tt->error();

and use MIME::Lite to send the email

(also, I wouldn't recommend to start variable names with caps)

--
John

Arachnids near Coyolillo - part 1
http://johnbokma.com/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com