summaryrefslogtreecommitdiffstats
path: root/t/safestring.t
diff options
context:
space:
mode:
Diffstat (limited to 't/safestring.t')
-rw-r--r--t/safestring.t35
1 files changed, 35 insertions, 0 deletions
diff --git a/t/safestring.t b/t/safestring.t
new file mode 100644
index 0000000..27d9ac1
--- /dev/null
+++ b/t/safestring.t
@@ -0,0 +1,35 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+use Text::Handlebars;
+use Text::Xslate 'mark_raw';
+
+my $tx = Text::Handlebars->new;
+
+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 &lt;p&gt; tags</i>' },
+ ),
+ '<h1>All About &lt;p&gt; Tags</h1><p><i>This is a post about &lt;p&gt; tags</i></p>',
+);
+
+is(
+ $tx->render_string(
+ '<h1>{{title}}</h1><p>{{{body}}}</p>',
+ { title => mark_raw('All About &lt;p&gt; Tags'), body => '<i>This is a post about &lt;p&gt; tags</i>' },
+ ),
+ '<h1>All About &lt;p&gt; Tags</h1><p><i>This is a post about &lt;p&gt; tags</i></p>',
+);
+
+done_testing;