[Dancer-users] Problem with PLACK

Alex Kapranoff kapranoff at gmail.com
Wed Jul 7 08:37:28 CEST 2010


Hello, Igor!

I can repeat your problem using your directions. Looks like
Plack::Middleware::Lint got enabled by default in development environments
somewhere in April and together with Dancer::Template::TemplateToolkit it
leads to your error.

There is a simple way to workaround the error. You may switch to
Template::Simple by commenting out "template" setting in config.yml.

Proper fix would be to apply this patch to your Dancer:
diff --git a/lib/Dancer/Template/TemplateToolkit.pm
b/lib/Dancer/Template/Templa
index 0e092db..4bdb717 100644
--- a/lib/Dancer/Template/TemplateToolkit.pm
+++ b/lib/Dancer/Template/TemplateToolkit.pm
@@ -19,6 +19,7 @@ sub init {
     my $tt_config = {
         ANYCASE   => 1,
         ABSOLUTE  => 1,
+        ENCODING  => 'utf8',
         %{$self->config},
     };

And then specify "charset: utf8" in config.yml.

(to all: we should think about making charset: utf8 the default)

Igor, can you test it?

-- 
Alex Kapranoff.

2010/7/7 <igor.bujna at post.cz>

>
> Hello,
> I have problem, when starting my dancer aplication with plackup and in
> template use UTF8 characters such as  "Čeština je pěkný jazyk".
> When I start aplication via Dancer start skript and after render the page,
> everything is ok. But when i start this via plackup and after render page i
> get message "body must be bytes and should not contain wide characters
> (UTF-8 strings)". This message is in file Plack/Middleware/Lint.pm in 'sub
> validate_res()' where test is:
>
>    if (ref $res->[2] eq 'ARRAY' && grep utf8::is_utf8($_), @{$res->[2]}) {
>        $croak->('body must be bytes and should not contain wide characters
> (UTF-8 strings).');
>    }
>
> When i comment this test the aplication, then run OK. I try this on
> http://github.com/sukria/ThisShit, when i put in main layout my UTF8 text
> "Čeština je pěkný jazyk".
> I think this problem is with plack, which can't use UTF8 text for rendering
> :(
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20100707/331cd636/attachment.htm>


More information about the Dancer-users mailing list