templates gets decoded twice #12

Closed
wanradt opened this Issue Nov 15, 2012 · 2 comments

Comments

Projects
None yet
2 participants
@wanradt

wanradt commented Nov 15, 2012

When i have utf-8 encoded data in variables but not in template,
everything works fine.

When i have utf-8 encoded data in templates too, Text::Haml dies with:
Cannot decode string with wide characters at
perl5/i686-linux-gnu-thread-multi-64int/Encode.pm line 175

AFAIU, problem is decoding twice: you open template file with binmode
utf8 enabled and then try to decode it once more at line 1017:

$tmpl = decode($self->encoding, $tmpl) if $self->encoding;

$self->encoding has default value as 'utf-8', so it is trying to
decode it once more, which fails, when template has utf-8 encoded
chars in (which are already decoded before this step).

I can provide a test case, script:

use strict;
use warnings;
use 5.010;
use Text::Haml;
use utf8::all;
# binmode STDOUT, ':utf8';

my $haml = Text::Haml->new;
$haml->cache(0);
my $html = $haml->render_file($ARGV[0], 
                                title => 'Журавли', 
                                content => 'Šaakal', 
                                sisu => 'Õrn ööbik'
);

print $html;

template:

!!!
%html
  %head
    %title= $title . " и другие"
  %body
    %tr
      %td= $content
      %td= $sisu

When i comment out line 1017 in Haml.pm, it works fine.

@vti

This comment has been minimized.

Show comment Hide comment
@vti

vti Dec 30, 2012

Owner

Please, try the latest version.

Owner

vti commented Dec 30, 2012

Please, try the latest version.

@wanradt

This comment has been minimized.

Show comment Hide comment
@wanradt

wanradt Dec 30, 2012

Thank you, it works now for me!

2012/12/30 Viacheslav Tykhanovskyi notifications@github.com

Please, try the latest version.


Reply to this email directly or view it on GitHubhttps://github.com/vti/text-haml/issues/12#issuecomment-11763015.

Kõike hääd,

G

wanradt commented Dec 30, 2012

Thank you, it works now for me!

2012/12/30 Viacheslav Tykhanovskyi notifications@github.com

Please, try the latest version.


Reply to this email directly or view it on GitHubhttps://github.com/vti/text-haml/issues/12#issuecomment-11763015.

Kõike hääd,

G

@vti vti closed this Dec 31, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment