File: synopsis_text_hogan_template.t

package info (click to toggle)
libtext-hogan-perl 2.01-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 240 kB
  • sloc: perl: 826; sh: 4; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 940 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env perl

use strict;
use warnings;

use Test::More;

use Text::Hogan::Compiler;

{
    my $template = Text::Hogan::Compiler->new->compile("Hello, {{name}}!");

    for (qw(Fred Wilma Barney Betty)) {
        is
            $template->render({ name => $_ }),
            "Hello, $_!",
            "Text::Hogan::Template synopsis works - $_";
    }
}

{ my $template = Text::Hogan::Compiler->new->compile("{{>hello}}");

    is
        $template->render({ name => "Dino" }, { hello => "Hello, {{name}}!" }),
        "Hello, Dino!",
        "Text::Hogan::Template synopsis works - Dino (partial)";
}

{
    my $template = Text::Hogan::Compiler->new->compile("Hello, {{name}}!", {'numeric_string_as_string' => 1});

    for (qw(01234)) {
        is
            $template->render({ name => $_ }),
            "Hello, $_!",
            "Text::Hogan::Template synopsis works - $_ (numeric_string_as_string)";
    }
}


done_testing();