In case somebody might find this useful:
Here's what I'm using in my templates, to get TT2 to drop in the
contents of another URL. (The ua.simple_request method and syntax
shown in Hans' example from last year didn't work for me.)
[% BLOCK httpquery %]
[% # 'ua' is a reference to an LWP::UserAgent
response = ua.get("$url");
response.content;
%]
[% END %]
...
[% PROCESS httpquery url =
'http://mydomain.com/banner_ad_generator.php' %]
This is letting me include (at the top of my site's pages) banner ads
that are generated as the output of a PHP banner ad script I'm very
happy with (phpAdsNew).
The quotes around $url turned out to be necessary, for some reason.
In my mod_perl handler that's processing the templates, I'm doing
this:
use LWP::UserAgent;
...
sub handler {
my $ua = LWP::UserAgent->new(env_proxy => 1,
keep_alive => 1,
timeout => 30,
);
...
$vars = {
ua => $ua,
...
};
...
Dave Baker
---------------------------------------------------
Hans Juergen von Lengerke Tue, 12 Feb 2002:
>Oscar Serrano <[EMAIL PROTECTED]> on Feb 12, 2002:
>
>> Is it possible to INSERT or INCLUDE a remote template?
>>
>> Something like this?
>>
>> <BODY>
>> [% INSERT "http://otherdomain.com/templates/remotetemplate.tt2"; %]
>> </BODY>
>
>It's not possible out of the box. But you could probably do something
>along the lines of:
>
>[% BLOCK httpquery %]
>[% # 'ua' is a reference to an LWP::UserAgent
> response = ua.simple_request('GET', $url);
> response.content;
>%]
>[% END %]
>
>[% INSERT httpquery("http://otherdomain.com/pelements/head.html";) %]
>[% PROCESS httpquery("http://otherodmain.com/templates/foo.tt2";) %]
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates