summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorShawn M Moore <code@sartak.org>2012-09-25 17:11:41 -0400
committerShawn M Moore <code@sartak.org>2012-09-25 17:11:41 -0400
commit16728b70b71e5cb06d636aba06d3188f2180b86c (patch)
tree373ac8535df83fe2f47431ce1a2fa9ed8c9a86c3 /t
parentebb77424883ed8fc76f82d3287f990c575edc05b (diff)
downloadtext-handlebars-16728b70b71e5cb06d636aba06d3188f2180b86c.tar.gz
text-handlebars-16728b70b71e5cb06d636aba06d3188f2180b86c.zip
SafeString and the trip-stache
Diffstat (limited to 't')
-rw-r--r--t/003-safestring.t32
1 files changed, 32 insertions, 0 deletions
diff --git a/t/003-safestring.t b/t/003-safestring.t
new file mode 100644
index 0000000..4cb35a5
--- /dev/null
+++ b/t/003-safestring.t
@@ -0,0 +1,32 @@
+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 &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>',
+);
+
+# XXX I'm not sure what the safestring constructor should be called
+# it's effectively Handlebars::SafeString->new($str) in JS
+is(
+ $tx->render_string(
+ '<h1>{{title}}</h1><p>{{{body}}}</p>',
+ { title => Handlebars::SafeString->new('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>',
+);