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 lib 't/lib';
use Test::More;
use Test::Handlebars;
use Text::Xslate 'mark_raw';
render_ok(
'<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>',
"raw body",
);
render_ok(
'<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>',
"raw body with html"
);
render_ok(
'<h1>{{title}}</h1><p>{{{body}}}</p>',
{
title => mark_raw('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>',
"raw title with manual mark_raw() call"
);
render_ok(
<<'TEMPLATE',
* {{name}}
* {{age}}
* {{company}}
* {{& company}}
TEMPLATE
{
name => 'Chris',
company => '<b>GitHub</b>',
},
<<'RENDERED',
* Chris
*
* <b>GitHub</b>
* <b>GitHub</b>
RENDERED
"mark_raw via &"
);
done_testing;
|