[EMAIL PROTECTED] wrote:
I'm adding a footer and I'm using HTML::Template. I'll be including a generic
footer using TMPL_INCLUDE and pass the current year to the included footer for
the copyright date.
What's the best way to send this info without having to explicitly sending a TMPL_VAR for the year each time? I'd like this to be automatic.
You can do this with a callback to 'load_tmpl':
sub my_load_tmpl_callback {
my ($self, $ht_params, $tmpl_params, $tmpl_file) = @_;
$tmpl_params->{YEAR} ||= current_year();
}
Setting up the callback can be done at several points, but I'd suggest doing
it inside setup() for simplicity:
sub setup {
my $self = shift;
# other setup stuff
# ...
# set default params
$self->add_callback('load_tmpl',\&my_load_tmpl_callback);
}
Refer to the CGI::Application docs for more information on callbacks.
HTH,
Rhesa
##### CGI::Application community mailing list ################
## ##
## To unsubscribe, or change your message delivery options, ##
## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ##
## ##
## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ##
## Wiki: http://cgiapp.erlbaum.net/ ##
## ##
################################################################