Subject: | before_template_render not being called if sitemap used as url |
Date: | Wed, 5 Mar 2014 16:25:30 +0000 |
To: | bug-Dancer-Plugin-SiteMap [...] rt.cpan.org |
From: | Keith Jones <scopa90 [...] gmail.com> |
Hello
first of all a small demo:
---- app.pl ----
use Dancer;
use Dancer::Plugin::SiteMap;
use Template;
hook before_template_render => sub
{
my $tokens = shift;
$tokens->{'demo'} = 'before_template_render called';
};
get '/' => sub
{
template 'index.tt';
};
dance;
----end of app.pl----
---- index.tt ----
<% demo %>
---- end of index.tt ---
if you bring app,pl up then a call to http://0.0.0.0:3000 will show:
[25950] core @0.000316> request: GET / from 127.0.0.1 in
/usr/local/lib/perl5/site_perl/5.18.2/Dancer/Handler.pm l. 56
[25950] core @0.001078> [hit #7]Trying to match 'GET /' against
/^\/sitemap\.xml$/ (generated from '/sitemap.xml') in
/usr/local/lib/perl5/site_perl/5.18.2/Dancer/Route.pm l. 84
[25950] core @0.001441> [hit #7]Trying to match 'GET /' against
/^\/sitemap$/ (generated from '/sitemap') in
/usr/local/lib/perl5/site_perl/5.18.2/Dancer/Route.pm l. 84
[25950] core @0.001760> [hit #7]Trying to match 'GET /' against
/^\/$/ (generated from '/') in
/usr/local/lib/perl5/site_perl/5.18.2/Dancer/Route.pm l. 84
[25950] core @0.002043> [hit #7] --> got 1 in
/usr/local/lib/perl5/site_perl/5.18.2/Dancer/Route.pm l. 102
[25950] core @0.003189> [hit #7]entering before_template_render hook
in /usr/local/lib/perl5/site_perl/5.18.2/Dancer/Hook.pm l. 58
[25950] core @0.006544> [hit #7]response: 200 in
/usr/local/lib/perl5/site_perl/5.18.2/Dancer/Handler.pm l. 179
And 'before_template_render called' will be displayed.
If you try http://0.0.0.0:3000/sitemap then you'll see:
[25950] core @0.001133> [hit #8]Trying to match 'GET /sitemap'
against /^\/sitemap\.xml$/ (generated from '/sitemap.xml') in
/usr/local/lib/perl5/site_perl/5.18.2/Dancer/Route.pm l. 84
[25950] core @0.001508> [hit #8]Trying to match 'GET /sitemap'
against /^\/sitemap$/ (generated from '/sitemap') in
/usr/local/lib/perl5/site_perl/5.18.2/Dancer/Route.pm l. 84
[25950] core @0.001807> [hit #8] --> got 1 in
/usr/local/lib/perl5/site_perl/5.18.2/Dancer/Route.pm l. 102
[25950] core @0.005524> [hit #8]response: 200 in
/usr/local/lib/perl5/site_perl/5.18.2/Dancer/Handler.pm l. 179
And a blank screen - you'll also note that the before_template_render
hook isn't called in the trace.