Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.


In reply to resolved: Converting code to use DATA filehandle instead of external templates by Spidy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-19 23:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found