I was stealing an idea from Catalyst::Helper and embedding my template files in the __DATA__ section of my code. But i was slightly annoyed by the way i had to read in the wrapper file and assign it as a scalar ref.
I was able to figure out how to make Template::Toolkit read directly from my __DATA__ section -- I figured it was useful enough to release it to CPAN -- Thus, Template::Provider::FromDATA was born.
Here's a little sample script you can play with to see how easy it is.
#!/usr/bin/perl
use strict;
use warnings;
use Template;
use Template::Provider::FromDATA;
my $provider = Template::Provider::FromDATA->new;
my $template = Template->new( {
LOAD_TEMPLATES => [ $provider ],
WRAPPER => 'wrapper'
} );
my $world = shift || 'world';
$template->process( 'hello', { world => $world } );
__DATA__
__wrapper__
header
[% content %]
footer
__hello__
Hello, [% world %]!