Subject: | handle HTML::Template with die_on_bad_params => 1 |
Currently, "it's a good idea to turn off 'die_on_bad_params' in
HTML::Template - in case this plugin tries to put in the parameters and
they're not available in your template".
Catching html_tmpl_class() would solve this problem. Here is my quick 'n
dirty workaround. I set
$self->param('__CAP_MessageStack_concering_templates') to a hashref of
template names, where CAP::MessageStack should insert its values.
[snip]
sub cgiapp_init {
$self->param('__CAP_MessageStack_concering_templates' => {
'/path/to/template.tmpl' => 1,
'another_tmpl_file.tmpl' => 1,
});
$self->capms_config(
-automatic_clearing => 1,
);
}
package CAP::MessageStack;
sub _pass_in_messages {
my ( $self, $one, $tmpl_params, $template_file ) = @_;
if( $self->html_tmpl_class() eq 'HTML::Template' ) {
my $concerning_templates =
$self->param('__CAP_MessageStack_concering_templates');
return unless defined $concerning_templates;
return unless exists $concerning_templates->{$template_file};
}
[/snip]
A proper way of doing this would probably be the use of the capms_config
method instead of param().
I imagine something like this:
sub cgiapp_init {
$self->param('__CAP_MessageStack_concering_templates' => {
'/path/to/template.tmpl' => 1,
'another_tmpl_file.tmpl' => 1,
});
$self->capms_config(
-automatic_clearing => 1,
-concering_templates =>
['/path/to/template.tmpl','another_tmpl_file.tmpl'],
);
}