Hans Juergen von Lengerke <[EMAIL PROTECTED]> writes: > 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 > url = 'http://otherdomain.com/pelements/head.html' > %] > [% PROCESS httpquery > url = 'http://otherodmain.com/templates/foo.tt2' > %]
You would rather want a little bit of error checking, though. The second block is likely not to insert anything unless otherodmain exists. > I do think though, that it shouldn't be too hard to patch TT2 to do the > LWP Stuff by itself when a file looks like a URI. For security reasons > this functionality would have to be enabled explicitly in the Template > Processor. I'd rather go for subclassing Template::Provider to allow URL-like things in INCLUDE_PATH. This could take care for caching as well, which IMHO is rather important if you fetch templates via the net. With the ability to say INCLUDE_PATH => "http://otherdomain.com/templates" a template could simply use [% INSERT remotetemplate.tt2 %] without fuzzing around with some user agent in the templates. -- Cheers, haj
