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 strict;
use warnings;
use Test::More;
use Text::Xslate;
my $tx = Text::Xslate->new(syntax => 'Handlebars');
is(
$tx->render_string(
'<h1>{{title}}</h1><p>{{{body}}}</p>',
{ title => 'My New Post', body => 'This is my first post!' },
),
'<h1>My New Post</h1><p>This is my first post!</p>',
);
is(
$tx->render_string(
'<h1>{{title}}</h1><p>{{{body}}}</p>',
{ title => 'All about <p> Tags', body => '<i>This is a post about <p> tags</i>' },
),
'<h1>All About <p> Tags</h1><p><i>This is a post about <p> tags</i></p>',
);
# XXX I'm not sure what the safestring constructor should be called
# it's effectively Handlebars::SafeString->new($str) in JS
# maybe we can just use Text::Xslate's mark_raw directly
is(
$tx->render_string(
'<h1>{{title}}</h1><p>{{{body}}}</p>',
{ title => Handlebars::SafeString->new('All about <p> Tags'), body => '<i>This is a post about <p> tags</i>' },
),
'<h1>All About <p> Tags</h1><p><i>This is a post about <p> tags</i></p>',
);
|