[Templates] template-toolkit and GD

Stefano stedis@antartide.org
Tue, 5 Nov 2002 20:41:12 +0100


On Fri, 25 Oct 2002 10:59:37 -0700
Pablo Velasquez <pablo_velasquez@citysearch.com> wrote:

> 
> Basically, I was hoping to do my calculations, send my $vars to a TT
> template that prints out an html table AND a nice graph on the same
> page. All in one go. The graph being dynamic since the reports will be
> different every time and I did hope to avoid having tons of png files
> to clean up later.
> 
> I suppose I may be asking for too much :-) 
> 

Yes, as other have already told you...

anyway what I did is this:

http://host/myscript/?p1=1&p2=2&p3=3

myscript produces HTML (Content-Type: text/html) like:

[...]
	<img src="/myscript_image_generator/?p1=1&p2=2&p3=3">
[...]
       
myscript_image_generator does :

 [...]
  $outvars = { $p1 => 1, $p2 => 2, $p3 => 3  } ;
  print "Content-Type: image/png\n\n" ; 

  $template->process('gd_image.tpl',$outvars)
     or die $template->error;

I haven't needed any temporary file otherwise /tmp is the only solution.

Two calls to the web server.

regards,
Stefano