Allow .html routes to call a sub

This commit is contained in:
Maxime Besson 2022-08-30 20:14:18 +02:00
parent 0119e3a229
commit 12ca5e62b9
1 changed files with 3 additions and 3 deletions

View File

@ -56,7 +56,7 @@ sub genRoute {
else {
$dest ||= $word;
}
if ( $dest =~ /^(.+)\.html$/ ) {
if ( $word =~ /^(.+)\.html$/ and $word eq $dest ) {
my $tpl = $1 or die;
$self->logger->debug("route $dest will use $tpl");
$routes->{$word} = sub { $self->sendHtml( $_[1], $tpl ) };
@ -305,8 +305,8 @@ the subroutine will be called with the word of path_info as second argument
=item 'something.html':
if $word finishes with '.html', then sendHtml() will be called with
'something.tpl' as template name. In this case, $dest is not used.
if $word finishes with '.html', and $dest is undef, then sendHtml() will be
called with 'something.tpl' as template name.
=back