in reply to Re: Template Toolkit: Output one template to Sendmail, another to browser?
in thread Template Toolkit: Output one template to Sendmail, another to browser?

Thanks.

I like the sounds of this:

A third parameter may be passed to the process() method to specify a different output location. This value may be one of: ..... a reference to a scalar... to which output/error is appended;

So if I understand this correctly, I can do

$template->process($template_file, $vars, $email_content) || die "Template process failed: ", $template->error(), "\n";
And TT will send the output to $email_content instead of to STDOUT. Then I can
send_html_mail($to, $from, $subject, $email_content);
Yes?

Replies are listed 'Best First'.
Re^3: Template Toolkit: Output one template to Sendmail, another to browser?
by clscott (Friar) on Aug 26, 2007 at 17:33 UTC
    You've almost got it. Your call to process should be:
    $template->process($template_file, $vars, \$email_content) || die "Template process failed: ", $template->error(), "\n";
    Notice the slash before $email_content. It creates a scalar reference that the manual says is required for the behaviour that you want.
    --
    Clayton
      Yep, that did it. Got me email template by email, and my confirmation template returned to browser.

      Thanks.