aboutsummaryrefslogtreecommitdiffstats
path: root/t/template.t
blob: 1763a7f120f504c250d83c1afc2938faedaea960 (plain)
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
use FixMyStreet::Test;

use_ok 'FixMyStreet::Template';

my $tt = FixMyStreet::Template->new;

my $output = '';
$tt->process(\'[% s %] [% s | safe %] [% s | upper %] [% s | html %]', {
    s => 'sp<i>l</i>it'
}, \$output);
is $output, 'sp&lt;i&gt;l&lt;/i&gt;it sp<i>l</i>it SP&lt;I&gt;L&lt;/I&gt;IT sp&lt;i&gt;l&lt;/i&gt;it';

$output = '';
$tt->process(\'[% s | html_para %]', { s => 'sp<i>l</i>it' }, \$output);
is $output, "<p>\nsp&lt;i&gt;l&lt;/i&gt;it</p>\n";

$output = '';
$tt->process(\'[% loc("s") %] [% loc("s") | html_para %]', {}, \$output);
is $output, "s <p>\ns</p>\n";

$output = '';
$tt->process(\'[% s.upper %] [% t = s %][% t %] [% t.upper %]', {
    s => 'sp<i>l</i>it'
}, \$output);
is $output, 'SP&lt;I&gt;L&lt;/I&gt;IT sp&lt;i&gt;l&lt;/i&gt;it SP&lt;I&gt;L&lt;/I&gt;IT';

$output = '';
$tt->process(\'H: [% s.split(":").join(",") %]', {
    s => '1:sp<i>l</i>it:3'
}, \$output);
is $output, 'H: 1,sp&lt;i&gt;l&lt;/i&gt;it,3';

done_testing;