Just bumped in to an interesting interaction between T::P::FDATA and
Proc::Daemon.
Given this sequence of events:
my $p = Template::Provider::FromDATA->new({ CLASSES => __PACKAGE__ });
...
Proc::Daemon::Init(); # Now running as a daemon
...
my $t = Template->new({
LOAD_TEMPLATES => [ $p ],
});
$t->process('template-name', { foo => bar });
__DATA__
__template-name__
My template [% foo %]
no templates are found. I think this is because Proc::Daemon::Init()
closes all open file handles (presumably, including DATA), so by the
time the provider comes to read from DATA it can't.
The solution is to call:
$p->get_file(__PACKAGE__, 'template-name');
before the call to Proc::Daemon::Init() (repeating the get_file() call
once for each template) so that the provider can load and cache them.
It might be a good idea of T::P::FD checked to see if *DATA has been
closed when it needs it, and re-opens it as necessary.