diff options
Diffstat (limited to 't/safestring.t')
-rw-r--r-- | t/safestring.t | 58 |
1 files changed, 40 insertions, 18 deletions
diff --git a/t/safestring.t b/t/safestring.t index 27d9ac1..29ec4ec 100644 --- a/t/safestring.t +++ b/t/safestring.t @@ -1,35 +1,57 @@ #!/usr/bin/env perl use strict; use warnings; +use lib 't/lib'; use Test::More; +use Test::Handlebars; -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!' }, - ), +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", ); -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>' }, - ), +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" ); -is( - $tx->render_string( - '<h1>{{title}}</h1><p>{{{body}}}</p>', - { title => mark_raw('All About <p> Tags'), body => '<i>This is a post about <p> tags</i>' }, - ), +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; |