Just thought I'd provide an update on this, to let people know what the resolution was; for reference...
On Tue, Feb 28, 2006 at 01:24:51PM -0500, Garrett, Philip (MAN-Corporate) wrote:
> You could subclass Template::Provider::fetch and add your mtime checking
> code to it. (*untested code*) e.g.
<snip>
> sub fetch {
> my $self = shift;
> my ($doc,$reason) = $self->SUPER::fetch(@_);
> $self->check_mtime($doc);
> return ($doc,$reason);
> }
<snip>
> I hope the code doesn't have too many bugs in it.
That works just fine, apart that if there's an error, SUPER::fetch()
returns a Template::Exception object instead. The fetch() method should
be coded to work around that, using ->isa() or something, to ensure it
only checks mtime for items that are Template::Documents.
Also, because I needed to embed the mtime in the generated output, I
found the following useful
$vars{mtime} = sub { $provider->get_latest_mtime() };
...
$template->process(..., \%vars, ...);
So that wherever "mtime" is used in the template, it includes the latest
mtime currently known at that point. If I prefill the object with the
mtime of the page template itself, and any of the WRAPPER templates
(because I know all these before I run ->process()), it ensures the
correct mtime is inserted into the page, as well as returned by HTTP.
"mtime" is only expanded in the WRAPPER template, and no further
INCLUDEs happen there.
--
Paul "LeoNerd" Evans
[EMAIL PROTECTED]
ICQ# 4135350 | Registered Linux# 179460
http://www.leonerd.org.uk/
signature.asc
Description: Digital signature
