|The stupid question is the question not asked|
Template Toolkit, and delaying the execution of a functionby elbie (Deacon)
|on Aug 18, 2001 at 03:31 UTC||Need Help??|
elbie has asked for the
wisdom of the Perl Monks concerning the following question:
Long story. My team has a group of custom libraries for inserting values into an HTML template within perl. Problem is these libraries were written way back when perl4 was da bomb.
When I try and use the -w option in a cgi that uses these libraries, I run into all sorts of problems. So I went looking for CPAN modules that I could replace bits of our library with. For this particular thing, the Template Toolkit seems to perform quite well, with one exception:
The old libraries could populate template variables with the output of functions which were run when the template parser reached the variable.
So far, I have no problem with setting up the perl Template object and changing tags to fit the old html templates and doing simple replacements, but when I try and use a function, the function runs at the very beginning of the script and I see the output at the top of the page instead of at the proper point in the template. I've included a small example below:
First the template file:
And the corresponding cgi:
So what I get is an enumerated list above the HTML headers, and SCALAR(0x82921d4) or similar where the list should go.
Granted, given enough time, I would just rewrite all the called subroutines, but for now I just need to drop something in place of my existing template functions.
Any help would be greatly appreciated.