File: 013_slurp_template.t

package info (click to toggle)
libtext-xslate-perl 3.5.9-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,108 kB
  • sloc: perl: 19,756; ansic: 214; pascal: 182; makefile: 9; cs: 8
file content (44 lines) | stat: -rw-r--r-- 902 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!perl -w
use strict;
use utf8;
use Test::More;

use Text::Xslate;
use Encode ();

use File::Path qw(rmtree);
use lib "t/lib";
use Util;
rmtree(cache_dir);
END{ rmtree(cache_dir) }

{
    package MyTemplate;
    our @ISA = qw(Text::Xslate);

    sub slurp_template {
        my($self, $input_layer, $fullpath) = @_;

        my $content = $self->SUPER::slurp_template($input_layer, $fullpath);
        return Encode::encode('cp932', $content);
    }
}

my $p = Encode::encode('cp932', 'エクスレート');

for(1 .. 2) {
    my $tx =  MyTemplate->new(
        path => [path],
        cache_dir => cache_dir,
    );


    is $tx->render('hello_utf8.tx', { name => $p }),
        Encode::encode('cp932', "こんにちは! エクスレート!\n");

    is $tx->render('hello_utf8.tx', { name => $p }),
        Encode::encode('cp932', "こんにちは! エクスレート!\n");
}
done_testing;