Spidy has asked for the wisdom of the Perl Monks concerning the following question:
Greetings, Fellow Monks.
I am currently working on a project where I am using HTML::Template to populate our template files with the output of our CGI scripts.
Recently, I stumbled accross the fact that you can pass an already opened filehandle in to HTML::Template's new() method.
I had the idea of converting my CGI scripts to store their templates inside themselves - using the __END__ token, like so:
#!/usr/bin/perl -w ## stuff here __END__ <html> <!--template stuff here--> </html>
However, I can't figure out how to actually pass the DATA filehandle to my "Page" module, which is what I'm using to control my templates and output.
The Page module takes a hash of parameters, one of which is the parameter "template". I would like to convert this to be the filehandle that gets passed in to HTML::Template's new() method, but cannot seem to figure out how (Currently, it's the filename that gets passed).
Does anyone know how I would pass the DATA filehandle into my module's constructor function, so that I can use it in a call to HTML::Template->new() within my module?
Thanks,
Spidy
Resolution: As it turns out, HTML::Template has a 'feature' where if you set cache => 1 when you're passing in a filehandle, it does not work.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Converting code to use DATA filehandle instead of external templates
by bobf (Monsignor) on Nov 20, 2007 at 05:02 UTC | |
Re: Converting code to use DATA filehandle instead of external templates
by snoopy (Curate) on Nov 20, 2007 at 06:29 UTC | |
Re: Converting code to use DATA filehandle instead of external templates
by naikonta (Curate) on Nov 20, 2007 at 06:29 UTC | |
by haoess (Curate) on Nov 20, 2007 at 08:39 UTC | |
Re: Converting code to use DATA filehandle instead of external templates
by GertMT (Hermit) on Nov 20, 2007 at 06:33 UTC |