From 16728b70b71e5cb06d636aba06d3188f2180b86c Mon Sep 17 00:00:00 2001 From: Shawn M Moore Date: Tue, 25 Sep 2012 17:11:41 -0400 Subject: SafeString and the trip-stache --- t/003-safestring.t | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 t/003-safestring.t (limited to 't') 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( + '

{{title}}

{{{body}}}

', + { title => 'My New Post', body => 'This is my first post!' }, + ), + '

My New Post

This is my first post!

', +); + +is( + $tx->render_string( + '

{{title}}

{{{body}}}

', + { title => 'All about

Tags', body => 'This is a post about <p> tags' }, + ), + '

All About <p> Tags

This is a post about <p> tags

', +); + +# 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( + '

{{title}}

{{{body}}}

', + { title => Handlebars::SafeString->new('All about <p> Tags'), body => 'This is a post about <p> tags' }, + ), + '

All About <p> Tags

This is a post about <p> tags

', +); -- cgit v1.2.3-54-g00ecf