Add plugin hook at sendHtml
Summary
It is sometimes convenient for plugins to be able to inject template variables, but only in some conditions.
Design proposition
Add a new hook called sendHtml, that receives the template name and Common::sendHtml args so that a plugin can:
- Change response code
- Change which template is sent
- Inject template args but only for some templates
example: a costly-to-generate template param that should be added to register.tpl:
sub generate_jwt_for_registration {
my ( $self, $req, $tpl, $args ) = @_;
if ($$tpl eq "register") {
my $jwt = $self->make_jwt($req);
if ($jwt) {
$args->{params}->{REGISTER_JWT} = $jwt;
}
}
return PE_OK;
}