in reply to Why won't my Dancer2 app render any output???
Hi,
One thing to note is that only the last engines block will have effect in your config (although that is clearly not the source of this problem).
I was able to reproduce your issue with the test app generated by dancer2 gen -a by adding a line after the template ... statement. My failing file:
The debug log statement was printed to the log but no output was shown in the browser. Removing/commenting the line fixed the problem. I believe this is because the output of the last line in the handler is what is returned to the browser. (From the doc: "Note that template simply returns the content, so when you use it in a route handler, if execution of the route handler should stop at that point, make sure you use return to ensure your route handler returns the content.") Adding a line with output shows this:package My::TestApp; use Dancer2; our $VERSION = '0.1'; get '/' => sub { template 'index' => { 'title' => 'My::TestApp' }; debug 'after templating'; }; true;
The browser shows 'foo' with this code.package My::TestApp; use Dancer2; our $VERSION = '0.1'; get '/' => sub { template 'index' => { 'title' => 'My::TestApp' }; debug 'after templating'; 'foo'; }; true;
Do you have any other code in the route handler in sandbox.pm after the template statement?
Hope this helps!
Update: added quote from the doc
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Why won't my Dancer2 app render any output???
by traveler (Parson) on Apr 06, 2025 at 21:06 UTC | |
by 1nickt (Canon) on Apr 06, 2025 at 23:27 UTC | |
by traveler (Parson) on Apr 07, 2025 at 02:23 UTC | |
by 1nickt (Canon) on Apr 07, 2025 at 10:19 UTC | |
by 1nickt (Canon) on Apr 06, 2025 at 23:20 UTC | |
by traveler (Parson) on Apr 06, 2025 at 23:25 UTC |