in reply to Re: Why won't my Dancer2 app render any output???
in thread Why won't my Dancer2 app render any output???

Thanks. I took out both debugs. Now I have:
get '/login' => sub { # Display a login page; the original URL they requested is availab +le as # param('requested_path'), so could be put in a hidden field in th +e form # debug "displaying login page"; template 'login', { path => param('requested_path') }; };
and still no output. I tried the "foo" and didn't see that either. I am getting the error:
[sandbox:22720] core @2025-04-06 16:28:17> Failed to serialize content +: hash- or arrayref expected (not a simple scalar, use allow_nonref t +o allow this) at /usr/local/share/perl/5.34.0/Dancer2/Serializer/JSON +.pm line 40. in (eval 333) l. 1
But I can't tell what's causing it. When I put the debug before the "template" call, the error vanished. Curious. Also, I have seen examples with multiple engines in the config. Can you point me to an example that says only one is allowed? I had 2 in the old working version. Updates: I found that beginning with 1.3091 it is again permitted to have statement after template. I did a debug template ... and the proper "output" is in the log. Now I need to figure out where it's going...

Replies are listed 'Best First'.
Re^3: Why won't my Dancer2 app render any output???
by 1nickt (Canon) on Apr 06, 2025 at 23:27 UTC

    I was able to produce that JSON error by adding set serializer => 'JSON'; to the app package, and then requesting the URI with the Accept header set to 'application/json'.

    Could that be the cause of your error?


    The way forward always starts with a minimal test.
      YES!

      Thank you! Thank you! Thank you! The site displays and functions correctly, now.

      I never would have found it otherwise!

        Great. Glad I could help. Happy Dancing.


        The way forward always starts with a minimal test.
Re^3: Why won't my Dancer2 app render any output???
by 1nickt (Canon) on Apr 06, 2025 at 23:20 UTC

    With regard to the engines question, from the config file created in the generated app:

    # NOTE: All the engine configurations need to be under a single "engines:"
    # key.  If you uncomment engine configurations below, make sure to delete
    # all "engines:" lines except the first.  Otherwise, only the last
    # "engines:" block will take effect.
    


    The way forward always starts with a minimal test.
      Thanks. Mine didn't have that comment.