MIME-Lite-TT-0.02000755 001751 001751 00000000000 10406440501 015005 5ustar00horiuchihoriuchi000000 000000 MIME-Lite-TT-0.02/t000755 001751 001751 00000000000 10406440501 015250 5ustar00horiuchihoriuchi000000 000000 MIME-Lite-TT-0.02/t/00_compile.t000644 001751 001751 00000000112 10406416255 017446 0ustar00horiuchihoriuchi000000 000000 use strict; use Test::More tests => 1; BEGIN { use_ok 'MIME::Lite::TT' } MIME-Lite-TT-0.02/MANIFEST000644 001751 001751 00000000206 10406440477 016227 0ustar00horiuchihoriuchi000000 000000 Changes lib/MIME/Lite/TT.pm Makefile.PL MANIFEST This list of files META.yml Module meta-data (added by MakeMaker) t/00_compile.t MIME-Lite-TT-0.02/META.yml000644 001751 001751 00000000646 10406440501 016343 0ustar00horiuchihoriuchi000000 000000 # http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: MIME-Lite-TT version: 0.02 version_from: lib/MIME/Lite/TT.pm installdirs: site requires: MIME::Lite: 0 Template: 0 Test::More: 0.32 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.17 MIME-Lite-TT-0.02/lib000755 001751 001751 00000000000 10406440501 015553 5ustar00horiuchihoriuchi000000 000000 MIME-Lite-TT-0.02/lib/MIME000755 001751 001751 00000000000 10406440501 016302 5ustar00horiuchihoriuchi000000 000000 MIME-Lite-TT-0.02/lib/MIME/Lite000755 001751 001751 00000000000 10406440501 017177 5ustar00horiuchihoriuchi000000 000000 MIME-Lite-TT-0.02/lib/MIME/Lite/TT.pm000644 001751 001751 00000005642 10406440235 020156 0ustar00horiuchihoriuchi000000 000000 package MIME::Lite::TT; use strict; use vars qw($VERSION); $VERSION = '0.02'; use MIME::Lite; use Template; use Carp (); sub new { my ($class, %options) = @_; %options = $class->_before_process(%options); if ( my $template = delete $options{Template} ) { my $tmpl_options = delete $options{TmplOptions} || {}; my %config = (ABSOLUTE => 1, RELATIVE => 1, %$tmpl_options, ); if ( $options{TmplUpgrade}) { $config{LOAD_TEMPLATES} = [MIME::Lite::TT::Provider->new(\%config)]; } my $tt = Template->new(\%config); my $tmpl_params = delete $options{TmplParams} || {}; $tt->process($template, $tmpl_params, \$options{Data}) or Carp::croak $tt->error; } %options = $class->_after_process(%options); MIME::Lite->new(%options); } sub _before_process { my $class = shift; @_; } sub _after_process { my $class = shift; @_; } package MIME::Lite::TT::Provider; use strict; use base qw(Template::Provider); sub _load { my $self = shift; my ($data, $error) = $self->SUPER::_load(@_); if(defined $data) { $data->{text} = utf8_upgrade($data->{text}); } return ($data, $error); } sub utf8_upgrade { my @list = map pack('U*', unpack 'U0U*', $_), @_; return wantarray ? @list : $list[0]; } 1; __END__ =head1 NAME MIME::Lite::TT - TT enabled MIME::Lite wrapper =head1 SYNOPSIS use MIME::Lite::TT; my $msg = MIME::Lite::TT->new( From => 'me@myhost.com', To => 'you@yourhost.com', Subject => 'Hi', Template => \$template, TmplParams => \%params, TmplOptions => \%options, ); $msg->send(); =head1 DESCRIPTION MIME::Lite::TT is the wrapper of MIME::Lite which enabled Template::Toolkit as a template of email. =head1 ADITIONAL OPTIONS =head2 Template The same value passed to the 1st argument of the process method of Template::Toolkit is set to this option. =head2 TmplParams The parameter of a template is set to this option. This parameter must be the reference of hash. =head2 TmplOptions configuration of Template::Toolkit is set to this option. ABSOLUTE and RELATIVE are set to 1 by the default. =head2 TmplUpgrade template is force upgraded. (means utf-8 flag turns on) =head1 SAMPLE use MIME::Lite::TT; my $template = < 'horiuchi'); my %options = (EVAL_PERL=>1); my $msg = MIME::Lite::TT->new( From => 'me@myhost.com', To => 'you@yourhost.com', Subject => 'hi', Template => \$template, TmplParams => \%params, TmplOptions => \%options, ); $msg->send(); =head1 AUTHOR Author Ehoriuchi@vcube.comE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L,L