summaryrefslogtreecommitdiffstats
path: root/t/blocks.t
blob: bbc22b9628e18207507143965259e7cdac302a55 (plain) (blame)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;

use Text::Handlebars;

my $tx = Text::Handlebars->new;

is(
    $tx->render_string(
        'This is {{#shown}}shown{{/shown}}',
        { shown => 1 },
    ),
    'This is shown',
);

is(
    $tx->render_string(
        'This is {{#shown}}shown{{/shown}}',
        { shown => 0 },
    ),
    'This is ',
);

is(
    $tx->render_string(
        'This is {{#shown}}shown{{/shown}}',
        { shown => [({}) x 3] },
    ),
    'This is shownshownshown',
);

is(
    $tx->render_string(
        'This is {{#shown}}{{content}}{{/shown}}',
        { shown => { content => 'SHOWN' } },
    ),
    'This is SHOWN',
);

is(
    $tx->render_string(
        'This is {{#shown}}{{content}}{{/shown}}',
        {
            shown => [
                { content => '3' },
                { content => '2' },
                { content => '1' },
                { content => 'Shown' },
            ],
        },
    ),
    'This is 321Shown',
);

done_testing;