1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
NAME
CGI::Application::Plugin::TT::LastModified - Set "Last-Modified" header
based on TT template
SYNOPSIS
# when you want to set the "Last-Modified" header manually
use base qw(CGI::Application);
use CGI::Application::Plugin::TT;
use CGI::Application::Plugin::TT::LastModified;
sub my_runmode {
my $self = shift;
my %params = (
# ...
);
my $html = $self->tt_process( 'template.html', \%params );
$self->tt_set_last_modified_header();
return $html;
}
# when you want the "Last-Modified" header set automatically
use base qw(CGI::Application);
use CGI::Application::Plugin::TT;
use CGI::Application::Plugin::TT::LastModified qw(:auto);
sub my_runmode {
my $self = shift;
my %params = (
# ...
);
return $self->tt_process( 'template.html', \%params );
}
DESCRIPTION
CGI::Application::Plugin::TT::LastModified adds support to
CGI::Application for setting a "Last-Modified" header based on the most
recent modification time of any of the components of a template that
was processed with TT.
Normally you'll want to call it manually, on as "as needed" basis; if
you're processing templates with TT you're most likely dealing with
dynamic content (in which case you probably don't even want a
"Last-Modified" header). The odd time you'll want to set a
"Last-Modified" header, though, this plugin helps make that easier.
If you have a desire to have the "Last-Modified" header set
automatically for you, though,
CGI::Application::Plugin::TT::LastModified does have an :auto import
tag which auto-registers "tt_set_last_modified_header()" as a
"tt_post_process" hook for you. If you've got an app that just
processes static TT pages and generates output, this will be useful for
you.
METHODS
import()
Custom import routine, which allows for tt_set_last_modified_header()
to be auto-added in as a TT post process hook.
tt_last_modified()
Returns the most recent modification time for any component of the
most recently processed template (via tt_process()). Time is returned
back to the caller as "the number of seconds since the epoch".
tt_set_last_modified_header()
Sets a "Last-Modified" header in the HTTP response, equivalent to the
last modification time of the template components as returned by
tt_last_modified().
AUTHOR
Graham TerMarsch (cpan@howlingfrog.com)
COPYRIGHT
Copyright (C) 2007, Graham TerMarsch. All Rights Reserved.
This is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
SEE ALSO
CGI::Application::Plugin::TT
CGI::Application
Template
|